日期:2014-05-17 浏览次数:20401 次
SELECT DISTINCT a.PCBSN
FROM adatabase a
WHERE a.Work_order='131A-13070298'
SELECT DISTINCT b.PCBSN
FROM bdatabase b
WHERE b.Work_order='131a-13070243'
SELECT DISTINCT PCBSN
FROM adatabase a
WHERE a.Work_order='131A-13070298'
and NOT EXISTS
(
SELECT b.PCBSN
FROM bdatabase b
WHERE b.Work_order='131a-13070243'
AND a.PCBSN = b.PCBSN
)
--a表中工单号相同但版本号b表中不存在的记录
select *
from adatabase a
where not exsists(select 1 from bdatabase b where b.Work_order=a.Work_order and a.PCBSN=b.PCBSN)
--b表中工单号相同但版本号a表中不存在的记录
select *
from bdatabase a
where not exsists(select 1 from adatabase b where b.Work_order=a.Work_order and a.PCBSN=b.PCBSN)
SELECT *
FROM
(
SELECT DISTINCT a.PCBSN
FROM adatabase a
WHERE a.Work_order='131A-13070298'
) a
FULL JOIN
(
SELECT DISTINCT b.PCBSN
FROM bdatabase b
WHERE b.Work_order='131a-13070243'
) b
ON a.PCBSN = b.PCBSN
WHERE a.PCBSN IS NULL OR b.PCBSN IS NULL
SELECT DISTINCT a.PCBSN