我写SQL声明,需要:
- Look for a job with a certain number
- Match that job to another table
- Show the results
这是我目前拥有的。
select * from PreviousJobs pj, Jobs j where jobId = 273121
AND where (pj.sOtherRef = j.sOtherRef) = True
毫米毫米
我写SQL声明,需要:
这是我目前拥有的。
select * from PreviousJobs pj, Jobs j where jobId = 273121
AND where (pj.sOtherRef = j.sOtherRef) = True
毫米毫米
不需要筑巢;这是需要的简单联合行动,最好用明确的连号符号写:
SELECT cj.*, pj.*
FROM PreviousJobs AS pj
JOIN Jobs AS cj ON pj.sOtherRef = cj.sOtherRef
WHERE cj.jobId = 273121
您不需要您的语句中的第二处( 语法错误, 您本应该向我们提供您 DBMS 所给你的错误信息) 。 您不需要比较 TRUE 。
在SQL-86和SQL-89中,条款中以逗号分隔的表格名称列表是必要的,但自SQL-92支持被添加到 DBMS 中以来就没有必要了。你应该知道这一点,这样如果你读到旧的 SQL,你知道这意味着什么。但是,你应该计划只使用新的 JOIN 符号,除非工作场所标准对使用旧的符号施加巨大的(和不明智的)压力。
取决于您使用的 DBMS 格式,您可能会发现表格中的AS 名是不允许的( Oracle), 尽管标准上说可以。 区别在于为什么将您的 DBMS 信息包含在问题中是一个好主意 。
你不需要True或者第二个地方
只是
select * from PreviousJobs pj, Jobs j where jobId = 273121
AND pj.sOtherRef = j.sOtherRef
查询将会是..
select *
from PreviousJobs pj inner join Jobs j ON pj.sOtherRef = j.sOtherRef
where j.jobId = 273121
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2
I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...
we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...
I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...
I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...