假设有两个表A,B,都只有一个字段PHONE 1,MINUS SELECT PHONE FROM A MINUS SELECT PHONE FROM B; 相当于用结果集A减去结果B得出的结果集.同样的效果也可以用SELECT PHONE FROM A WHERE NOT EXISTS(SELECT 1 FROM B WHERE A.PHOEN=B.PHONE)来达到. 2,INTERSECT SELECT PHONE FROM A INTERSECT SELECT PHONE FROM…
------distinct 去重复查询 select * from accounts acc join (select distinct accid from roles) r on r.accid=acc.ID -----不需要distinct select * from (select MAX(ID)roleid,accid from roles group by accid) rr join (select * from accounts) acc on acc.ID=rr.accid…
-------distinct 去重复查询 select * from accounts acc join (select distinct accid from roles) r on r.accid=acc.ID -----不需要distinct select * from (select MAX(ID)roleid,accid from roles group by accid) rr join (select * from accounts) acc on acc.ID=rr.acci…
Oracle 取两个表中数据的交集 关键字: Oracle 取两个表中数据的交集 INTERSECT Oracle 作为一个大型的关系数据库,日常应用中往往需要提取两个表的交集数据 例如现有如下表,要求找出工资2500(不含2500)以上并且是男性(M)的员工编号,那么就要利用这两个表的关系做一个交集了 employee CODE NAME GENDER 001 Tom M 002 Jerry M 003 Ana F salary CODE SALARY 001 2800 002 2500 00…