if pk exists in both Table A and B, ignor record in Table B
if pk exist either in Table A or B, return it
think should union 3:
SELECT A.PK AS A_PK, A.Value AS A_Value FROM Table_A A INNER JOIN Table_B B ON A.PK = B.PK
UNION
SELECT A.PK AS A_PK, A.Value AS A_Value FROM Table_A A LEFT JOIN Table_B B ON A.PK = B.PK WHERE B.PK IS NULL
UNION
SELECT B.Value AS B_Value, B.PK AS B_PK FROM Table_A A RIGHT JOIN Table_B B ON A.PK = B.PK WHERE A.PK IS NULL
hope it works
what I want is:
所有跟帖:
•
開始又不說清楚,哎
-令狐衝衝-
♀
(0 bytes)
()
03/05/2013 postreply
20:09:15
•
墨索裏尼總是有理,過去有理,現在有理,而且將來永遠有理
-奉旨灌水-
♀
(87 bytes)
()
03/05/2013 postreply
20:13:21
•
這啥呀?
-令狐衝衝-
♀
(0 bytes)
()
03/05/2013 postreply
20:14:47
•
這句名言出自一部阿爾巴尼亞的電影,電影的名子是《寧死不屈》。
-奉旨灌水-
♀
(320 bytes)
()
03/05/2013 postreply
20:19:59
•
估計你的父母都不一定看過,嘿嘿
-奉旨灌水-
♀
(4 bytes)
()
03/05/2013 postreply
20:21:09
•
直接用not exists 不就行了?搞的這麽複雜
-令狐衝衝-
♀
(0 bytes)
()
03/05/2013 postreply
20:13:46
•
how to deal exist? 不搞的這麽複雜
-奉旨灌水-
♀
(90 bytes)
()
03/05/2013 postreply
20:15:54
•
回複:how to deal exist? 不搞的這麽複雜
-令狐衝衝-
♀
(230 bytes)
()
03/05/2013 postreply
20:21:46
•
OK, I'll try. Thanks, vielen dank.Merci, תוד&#
-奉旨灌水-
♀
(0 bytes)
()
03/05/2013 postreply
20:25:40