如圖 查找a表和b表中 不同的資料 并同時展示
uj5u.com熱心網友回復:
select a.sku1,a.sl1,b.sku2,b.sl2
from 表a a
full join 表b b on a.sku1=b.sku2
where a.sl1<>b.sl2
uj5u.com熱心網友回復:
版主,留點積分給我們咯。
uj5u.com熱心網友回復:
-->測驗資料if OBJECT_ID('ta') is not null drop table ta
if OBJECT_ID('tb') is not null drop table tb
create table ta(suk1 varchar(2),sl1 int)
create table tb(suk2 varchar(2),sl2 int)
insert into ta
select 'a1',1 union all
select 'a2',2 union all
select 'a3',3
insert into tb
select 'a1',1 union all
select 'a2',3 union all
select 'a4',4 union all
select 'a5',5
-->開始查詢
select * from (
select * from ta where not exists(select * from tb where ta.suk1=tb.suk2 and ta.sl1=tb.sl2))a
full join (
select * from tb where not exists(select * from ta where ta.suk1=tb.suk2 and ta.sl1=tb.sl2)) b
on a.suk1=b.suk2 and a.sl1<>b.sl2
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/146850.html
標籤:疑難問題
上一篇:用sql根據訂單分配庫存的問題
