select * from a except select * from b差异(Except)就是两个集中不重复的部分。例如SELECT * FROM AEXCEPTSELECT * FROM B这个的意思是,凡是不出现在B表中的A表的行。 如果要比较score的差异: 可以直接写select查询语句,比较score的值 select score from 表1 select typescore from 表2
innot in 可以实现了。
可以考虑使用一个 full join ,没有的数据全为 NULL。
select * from tablea a left outer join tableb b on a.xx=b.xx where b.xx is null select * from tableb a left outer join tablea b on a.xx=b.xx where b.xx is nullSQL语句大概这样写。试试看。
******************* 把两个表合成一个表 select sortname as name,'A' as type from A表 group by sortname UNION ALL select typename as name,'B' as type from B表 group by typename********************计算数据数量 SELECT name, COUNT(name) AS 数量 FROM ??? GROUP BY name ********************************** 上面两条命令可以实现你想要的功能,怎么合成一条命令你自己想吧~~
http://www.cnblogs.com/lyhabc/p/4176269.html
select * from a except select * from b差异(Except)就是两个集中不重复的部分。例如SELECT * FROM AEXCEPTSELECT * FROM B这个的意思是,凡是不出现在B表中的A表的行。
如果要比较score的差异:
可以直接写select查询语句,比较score的值
select score from 表1
select typescore from 表2
可以实现了。
select * from tableb a left outer join tablea b on a.xx=b.xx where b.xx is nullSQL语句大概这样写。试试看。
select sortname as name,'A' as type from A表 group by sortname
UNION ALL
select typename as name,'B' as type from B表 group by typename********************计算数据数量
SELECT name, COUNT(name) AS 数量
FROM ???
GROUP BY name
**********************************
上面两条命令可以实现你想要的功能,怎么合成一条命令你自己想吧~~