总结 sql 的 并集、交集、差集
有两个表 ,表a ,表b ,
create table a { age int , name varchar(20) } ending=innodb;
insert into a values(13,cen);
insert into a values(18,yue);
create table b { age int , name varchar(20) } ending=innodb;
insert into b values(13,cen);
insert into b values(16,tom);
1.并集
select * from a union select * from b;
2.交集
select * from a a1 where exists (select * from b b1 where a1.age = b1.age and a1.name = b1.name);
3.差集
select * from a a1 where not exists(select * from b1 where a1.age = b1.age and a1.name = b1.name);
本文来自博客园,作者:岑惜,转载请注明原文链接:https://www.cnblogs.com/c2g5201314/p/13166780.html
响应开源精神相互学习,内容良币驱除劣币