gpt4 book ai didi

mysql - SQL选择: fits both id's

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

您能帮我查询数据库吗,我需要选择具有相同组合 ID 的产品。例如 ID 为 70 和 75 的产品。它们都有过滤器 1 和 12。

IN 不起作用,它还需要#66,因为它有过滤器 1,但第二个是 11,这不是我需要的......

  product_id | filter_id
______________________
66 | 1
66 | 11
68 | 9
69 | 13
70 | 1
70 | 12
71 | 14
72 | 4
72 | 17
73 | 7
73 | 14
74 | 16
75 | 1
75 | 12

最佳答案

试试这个:

SELECT t1.*
FROM table AS t1
JOIN table AS t2 ON t1.product_id = t2.product_id
WHERE t1.filter = 1
AND t2.filter = 12

关于mysql - SQL选择: fits both id's,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26463665/

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