选择MySQL中的Distinct

时间:2016-02-29 20:22:05

标签: mysql sql

如何返回Await的唯一记录?我知道如何使用AccountDescription,但我不确定如何在这种情况下应用它。

distinct

我基本上需要获取所有唯一 SELECT Contacts.FirstName, Contacts.LastName, Account.AccountType, Account.AccountDescription FROM Contacts INNER JOIN Account ON Contacts.UserID = Account.AccountID WHERE UserAccountType LIKE '%TEST%' AND AccountType = 'trial' ,因为有许多联系人具有相同的AccountDescription

我目前的回归:

AccountDescription

我需要抓住唯一的AccountType : Trial , AccountDescription : test1 AccountType : Trial , AccountDescription : test2 AccountType : Trial , AccountDescription : test1

2 个答案:

答案 0 :(得分:0)

尝试此查询:

SELECT DISTINCT Contacts.FirstName, Contacts.LastName,
Account.AccountType, Account.AccountDescription
FROM Contacts INNER JOIN Account ON Contacts.UserID = Account.AccountID
WHERE UserAccountType LIKE '%TEST%' AND AccountType = 'trial'

答案 1 :(得分:0)

我自己使用GROUP BY AccountDescription;

解决了这个问题