您的位置:首页 > 数据库

sql not exists 用法

2016-03-23 18:30 423 查看
选择存在于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, name, gender, classId from tA  where name  not  in (select name from tB  where tA.name=tB.name)

或者

select id, name, gender, classId from tA  where name  not  in (select name from tB)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: