选择存在于tA表中,但其中name不同于tB表中的数据
select id,name,gender,classId from tA where not exists (select name from tB where tA.name=tB.name)
not in 的写法,同样的效果,但是在大数据量的时候效率不高
select id,classId from tA where name not in (select name from tB where tA.name=tB.name)
或者
select id,classId from tA where name not in (select name from tB)
如果选取和排除的字段数目相等,还可以用except方法,但是注意它会去除重复的数据(有点类似于union和union all的区别,不过并没有except all这种用法)
select name from tA except select name from tB
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。