集合操作-差

来源:互联网 发布:虚拟机mac os x 流畅 编辑:程序博客网 时间:2024/05/09 19:57

而有时候我们需要查下不是演员的员工。这时候就用到集合操作-差。SQL语句如下:

select id from employee

except

select yid from yanyuan

同样,对于不支持except关键字的DBMS,可以用下面的SQL语句替代:

select id 

from employee

where id not in (select yid from yanyuan )

也可以用exists函数来完成上面的这个操作:

select id from employee

where not exists(select * from yanyuan where id=yid)

查询结果如下:


原创粉丝点击