l********u 发帖数: 195 | 1 table 1
product no. description
001 aa
002 bb
003 cc
table 2
Product no transcaction
001 111
001 222
003 rrr
how can I write query to find the product in table 1 that doesn't have any
transaction in table 2. query should return 2 by using the above data. |
R*********r 发帖数: 225 | 2 SELECT t1.ProductNumber FROM
Table1 t1
LEFT JOIN Table2 t2 ON
t2.ProductNumber = t1.ProductNumber
WHERE t2.ProductNumber IS NULL
【在 l********u 的大作中提到】 : table 1 : product no. description : 001 aa : 002 bb : 003 cc : table 2 : Product no transcaction : 001 111 : 001 222 : 003 rrr
|
l********u 发帖数: 195 | 3 we need to put this query into a tool. however the tool has
"select * from table t1 where" hardcoded, left join is before where, so how
can I left join with query start with select * from where |
B*****g 发帖数: 34098 | 4 not exists
how
【在 l********u 的大作中提到】 : we need to put this query into a tool. however the tool has : "select * from table t1 where" hardcoded, left join is before where, so how : can I left join with query start with select * from where
|
l********u 发帖数: 195 | 5 we need to put this query into a tool. however the tool has
"select * from table t1 where" hardcoded, left join is before where, so how
can I left join with query start with select * from where |
l********u 发帖数: 195 | 6 beijing code pls. thanks
【在 B*****g 的大作中提到】 : not exists : : how
|
B*****g 发帖数: 34098 | 7 NOT EXSITS (SELECT 1 FROM table2 t2 WHERE t2.no = t.no)
or
no NOT IN (SELECT no FROM table2 t2)
【在 l********u 的大作中提到】 : beijing code pls. thanks
|