如何从table1中选择用户3,4,5,因为它们的数字在表2上不是100?
**table1 table2**
id name id number
1 user1 1 100
2 user2 2 100
3 user3 3 200
4 user4 4 200
5 user5 1 300
2 300
答案 0 :(得分:0)
select name,id from table1 where id not in
(select id from table2 where number=100)
答案 1 :(得分:0)
使用NOT EXISTS
验证同一个ID在table2中没有数字100.
select *
from table1 t1
where not exists (select 1 from table2 t2
where t2.number = 100
and t2.id = t1.id)