我有表Creditcard
,Childcreditcard1
,Childcreditcard2
SQL查詢問題加入
Childcreditcard1
CreditcardID TranscationDatetime
22222132132 2010-04-11 12:36:10.210
22222132134 2011-04-11 12:36:10.210
12364132122 2019-04-11 12:36:10.210
45677132124 2011-04-11 12:36:10.210
45677132124 2012-04-11 12:36:10.210
Childcreditcard2
CreditcardID TranscationDatetime
22222132132 2010-04-11 12:36:10.210
22222732134 2011-04-11 12:36:10.210
12364132192 2019-04-11 12:36:10.210
MasterCreditcard
CreditcardID primaryCreditID
22222132132 22222132132
22222132134 22222132132
12364132122 12364132122
45677132124 45677132124
45677232124 45677232124
78567723212 78567723212
23677232124 23677232124
45678944343 45678944343
22222732134 22222732134
12364132192 12364132192
現在這三個表我需要得到creditcardID
僅從MasterCreditcard
任何CreditcardID
我們在Childcreditcard1
,Childcreditcard2
表將永遠存在於MasterCreditcard
表
結果應該是表應該喜歡這個
這不匹配45677232124
78567723212
23677232124
45678944343
我的查詢:
select
distinct(cc.CreditcardID)
from
MasterCreditcard CC
inner JOIN
Childcreditcard1 c1 ON CC.CreditcardID <> c1.CreditcardID
inner JOIN
Childcreditcard2 c2 ON CC.CreditcardID <> c2.CreditcardID
我想這樣,但是這給結果所有CreditcardID
在MasterCreditcard
表這是不對的
就是答案對你有幫助嗎? – 2012-04-11 13:17:03