mdsk.net
当前位置:首页 >> sql如何查询A表里有而B表里没有的数据的数据总和 >>

sql如何查询A表里有而B表里没有的数据的数据总和

select * from a where not exists ( select 1 from b where b的一个字段=a表中的一个字段)

SELECT A.户名FROM TABLE_A A, TABLE_B BWHERE A.户名 = B.户名(+)WHERE B.户名 IS NULL还可以有其他方法:1 select distinct A.ID from A where A.ID not in (select ID from B)1 select A.ID from A left join B on A.ID=B.ID where B.ID is null

select * from a where id not in (select id from b)

你好!select * from A where not exists (select 1 from B where A.bid = B.bid)打字不易,采纳哦!

EXISTS写法:SELECT A.条码 FROM TABLE1 A WHERE EXISTS(SELECT 1 FROM TABLE2 B WHERE A.条码 = B.ITEM_NO); INNER JOIN写法:SELECT A.*,B.* FROM TABLE1 A INNER JOIN TABLE2 B ON A.条码 = B.ITEM_NO; 还有其他的写法.小表关联可以用IN SELECT A.* FROM TABLE1 A WHERE A.条码 IN(SELECT B.ITEM_NO FROM TABLE2 B)

左连Left Join 表B中存了表A要的信息,相连字段假设是AID,即B表中有个字段AID,是与A表中ID相关联的 SELECT A.*, B.你要的字段 FROM A LEFT JOIN B ON A.ID = B.AID

select * from B表 where item_no in (select 条码 from A表) select * from A表,B表 where A表.条码=B表.item_no 你看看这两个哪个符合你要求

select name from A where name not in (select name from B)有问题再追问,望采纳.

保留A表全部结果需要和b表左外连接,查询wx:select a.*, b.enable from a left join b on a.sid=b.sid where b.staff_id='wx'查询admin:select a.*, b.enable from a left join b on a.sid=b.sid where b.staff_id='admin'

第一个问题:select name1 from 表a minus select name1 from 表b第二个问题:select a.*,b.* from 表a a,表b b where a.name1=b.name1

相关文档
网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com