sql查询表2的资料,要求表1中没有相同记录的显示

来源:百度知道 编辑:UC知道 时间:2024/05/24 04:07:31
要显示表2的资料,但是要求把表1中有相同公司名的不显示怎么写呀
是不是select * from 表2 where not in (select * 表2 where 表2.公司名=表1.公司名)这样的

select * from 表2 where 公司名 not in (select 公司名 from 表1)

select b.* from 表1 a,表2 b where a.公司名<>b.公司名

用in和not in执行效率不好,用连接查询吧。。
但是你没给出具体的列名,我没办法帮你写,如果你有需要再HI我吧