第四章 求交集--intersect运算
select * from staff
intersect
select * from staff_copy;
mysql不支持,需要通过自己实现
SELECT id,name,level from (
SELECT id ,name ,level from staff
UNION ALL
SELECT id ,name ,level from staff_copy
)a
GROUP BY id,name,level
HAVING count(*)>1
如果字段名称不一样的话需要
SELECT c_id,name,level from (
SELECT id as c_id,name ,level from staff
UNION ALL
SELECT id1 as c_id ,name ,level from staff_copy
)a
GROUP BY c_id,name,level
HAVING count(*)>1
浙公网安备 33010602011771号