这个查询结果怎么得到啊
tab1:
wpbh yuan syue
01 200 1
02 300 3
03 500 5
tab2:
wpbh yuan
01 300
04 300
两个表查询,怎么得到如下的记录
wpbh yuan syue wpbh yuan
01 200 1 01 300
02 300 3 02 0
03 500 5 03 0
04 0 0 04 300
------解决方案--------------------select isnull(a.wpbh, b.wpbh),isnull(a.yuan,0),isnull(a.syue,0),isnull(a.wpbh, b.wpbh),isnull(b.yuan,0)
from tab1 aa
full join tab2 b on a.wpbh = b.wpbh and a.yuan = b.yuan
------解决方案--------------------Select
IsNull(A.wpbh, B.wpbh) As wpbh1,
IsNull(A.yuan, 0) As yuan1,
IsNull(A.syue, 0) As syue,
IsNull(A.wpbh, B.wpbh) As wpbh2,
IsNull(B.yuan, 0) As yuan2
From
tab1 A
Full Join
tab2 B
On A.wpbh = B.wpbh