gpt4 book ai didi

mysql - 其中公司 =(不同公司)

转载 作者:行者123 更新时间:2023-11-29 11:58:40 25 4
gpt4 key购买 nike

嘿,我想从表中获取一些数据行。但不想让公司翻倍。所以我想使用 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 | m.master@dell.com | dellstreet | chicago | 543478 | 543267
DELL | John | Doe | j.doe@dell.com | dellstreet | chicago | 543462 | 543267
SHELL | Charlie | Fame | charlie@shell.com | nicestreet | shelltown | 5546546 | 54535

期望:

Company | Firstname | Surname | eMail             | Adress     | Place     | Phone   | Fax
DELL | Max | Master | m.master@dell.com | dellstreet | chicago | 543478 | 543267
SHELL | Charlie | Fame | charlie@shell.com | nicestreet | shelltown | 5546546 | 54535

最佳答案

您不能以这种方式使用distinct。而是使用分组依据:

SELECT column1, Company, - column10 FROM `contact_list` 
GROUP BY company

关于mysql - 其中公司 =(不同公司),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32759267/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com