有两个表 ,表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);