2012-02-06 143 views
0

我已經在TABLE_1從A到Z 場我也一直在與TABLE_2域B,G和PSQL Server 2005 LEFT JOIN?

我怎麼能找到的所有記錄從TABLE_1 不是

TABLE_1.B = TABLE_2.B 
TABLE_1.G = TABLE_2.G 
TABLE_1.P = TABLE_2.P 

在SQL Server 2005中?

+0

這些條件是包容還是排斥? – JNK 2012-02-06 18:46:05

回答

3
SELECT t1.* 
    FROM TABLE_1 t1 
    WHERE NOT EXISTS(SELECT 1 
         FROM TABLE_2 t2 
         WHERE t1.B = t2.B 
          AND t1.G = t2.G 
          AND t1.P = t2.P)