嘿,我想从表中获取一些数据行。但是不想让公司翻倍。所以我想使用DISTINCT子句来减少公司。这样的事情可能吗?
SELECT Company, Firstname, Surname, eMail, Adress, Place, Phone, Fax FROM `contact_list`
WHERE Company = (DISTINCT Company as `compName`)
从:
Company | Firstname | Surname | eMail | Adress | Place | Phone | Fax
DELL | Max | Master | [email protected] | dellstreet | chicago | 543478 | 543267
DELL | John | Doe | [email protected] | dellstreet | chicago | 543462 | 543267
SHELL | Charlie | Fame | [email protected] | nicestreet | shelltown | 5546546 | 54535
期望:
Company | Firstname | Surname | eMail | Adress | Place | Phone | Fax
DELL | Max | Master | [email protected] | dellstreet | chicago | 543478 | 543267
SHELL | Charlie | Fame | [email protected] | nicestreet | shelltown | 5546546 | 54535
最佳答案
您不能以这种方式使用distinct
。而是使用group by
:
SELECT column1, Company, - column10 FROM `contact_list`
GROUP BY company
关于mysql - WHERE公司=(独立公司),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32759267/