简单的SQL JOIN问题

时间:2012-09-15 15:58:30

标签: sql sql-server-2005 join

我有一个简单的JOIN我遇到了下面SQL的问题。此语句返回1条记录,但如果我注释掉第5行,则它不会返回任何记录。有什么想法吗?

SELECT A.district__c, b.annual_conference__c
FROM   Contact_UpdateDistricts A
JOIN   Contact B on a.id = b.id
WHERE  A.error NOT LIKE '%success%'
and a.id = '003Z000000C80tUIAR'
and A.district__c <> b.annual_conference__c

1 个答案:

答案 0 :(得分:1)

我最终为决议投了最后一个条款:

SELECT A.district__c, b.annual_conference__c 
FROM Contact_UpdateDistricts A 
JOIN Contact B on a.id = b.id 
WHERE A.error NOT LIKE '%success%' 
and CAST(A.district__c AS VARCHAR(18)) <> CAST(b.annual_conference__c AS VARCHAR(18))