首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教这个查询已经怎么实现

2012-03-23 
请问这个查询已经如何实现?有两个表table1 和 table2,分别有字段为 货号及数量现按以下要求找出table1在ta

请问这个查询已经如何实现?
有两个表table1 和 table2,分别有字段为 货号及数量
现按以下要求找出
table1在table2没有的货号;另外table1和table2货号相同,但是数量不同的货号



[解决办法]

SQL code
方法一:select m.货号 from table1 m where m.货号 not in (select 货号 from table2)union allselect m.货号 from table1 m , table2 n where m.货号 = n.货号 and m.数量 <> n.数量方法二:select m.货号 from table1 m where not exists (select 1 from table2 n where n.货号 = m.货号)union allselect m.货号 from table1 m , table2 n where m.货号 = n.货号 and m.数量 <> n.数量 

热点排行
Bad Request.