2012-06-08 140 views

回答

1

如果您不想要NULL結果,請使用INNER JOIN。

SELECT DISTINCT(u2.email) FROM users u1 
    INNER JOIN users u2 ON u1.email = u2.email AND u1.id <> u2.id 

如果你必須使用LEFT JOIN:

SELECT DISTINCT(u2.email) FROM users u1 
    LEFT JOIN users u2 ON u1.email = u2.email AND u1.id <> u2.id 
    WHERE u2.email IS NOT NULL 
+0

我必須用左手做JOIN – Donovant

+1

幾乎與INNER JOIN然後以同樣的方式。我用LEFT JOIN方法編輯了我的答案。 –