答案 0 :(得分:0)
select isnull(a.date, b.date), isnull(a.seller, b.seller), a.[theoretical itinerary], b.[real itinerary]
from table1 a full join table2 b
on a.date=b.date and a.seller=b.seller
答案 1 :(得分:0)
我想你想要full join
:
select coalesce(t.date, r.date) as date, coalesce(t.seller, r.seller) as seller,
t.itinerary as theoretical_itinerary,
r.itinerary as real_itinerary
from theoretical t full join
real r
on t.date = r.date and t.seller = r.seller;
coalesce()
是使用full join
的不幸神器。如果您不包含它,那么您将看到匹配列的NULL
值。 (如果只支持SQL Server using
,则会有一个简单的替代方案。)