這應該是很容易的,但我只是無法找出這一個。選擇哪裏有超過2個非重複的記錄sql
瞭解了客戶訂單信息。該表中有一個名爲customers_email_address和customers_id的字段以及一些其他非必要字段。我需要找到不同記錄,其中位於customers_email_address字段中的條目不同但對同一customers_id唯一。換句話說,我需要了解客戶自從帳戶開始以來在其帳戶中更改了他們的電子郵件地址,因此我可以用他們的新電子郵件地址更新我的電子郵件廣告程序。我在設計網站時沒有想到的東西!
也許一個例子是:查詢
customers_ID customers_email_address
1 [email protected]
2 [email protected]
1 [email protected]
2 [email protected]
1 [email protected]
2 [email protected]
3 [email protected]
3 [email protected]
3 [email protected]
結果應該是這樣的:
customers_id customers_email_address
1 [email protected]
1 [email protected]
2 [email protected]
2 [email protected]
只有返回,其中customers_email_address字段有多個不重複的記錄,但相同的customer_id
也許更好的東西會是這樣的:
customers_id customers_email_address1 customers_email_address2
1 [email protected] [email protected]
2 [email protected] [email protected]
我希望這是有道理的。如果你有更好的主意,請隨時加入。
無論如何,感謝您的幫助球員。
請出示當前的查詢和表結構。最好通過sqlfiddle – Wolph