gpt4 book ai didi

mysql - SQL 查询从同一列中选择多个值

转载 作者:行者123 更新时间:2023-11-29 03:50:44 24 4
gpt4 key购买 nike

这是我的 table 。

id  customer        product 
1 Tizag Pen
4 Gerald Garner 19" LCD Screen
5 Tizag 19" LCD Screen

我想选择同时拥有“Pen”和“19”LCD Screen'的客户。因此,结果为客户“Tizag”。

我该怎么做。

感谢和问候,鲁帕克类纳吉。

最佳答案

试试这个:

SELECT customer FROM table t1
JOIN table t2 USING( customer )
WHERE t1.product = 'Pen'
AND t2.product = '19" LCD Screen'

但是,如果您更改产品数量,则需要更改查询。可能有更好的方法来执行此操作,但我认为这会起作用。

关于mysql - SQL 查询从同一列中选择多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9708925/

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