有2张桌子。表1具有一个ID,该ID在表2中具有多个条目。我需要选择一个没有特定记录的ID(在表2中的那些多个记录中,不应仅存在一行)。请告诉我该怎么做。
例如:
Table 1 Table 2
A A 2
B A 3
C B 2
B 3
C 3
现在,我需要从表1中选择与表2中包含值的行不相关的行2
(即应选择C)。
你可以尝试这样的事情
select t1.*
from table1 as t1
left join table2 as t2 on (t1.col1 = t2.col1)
where t2.col2 is null
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句