gpt4 book ai didi

mysql - WHERE IN 语句中的多个选择查询

转载 作者:太空宇宙 更新时间:2023-11-03 11:37:13 24 4
gpt4 key购买 nike

我有以下 sql 查询:

SELECT `main_table`.* FROM `prd_brand` AS `main_table`
INNER JOIN
(SELECT DISTINCT value from catalog_product_entity_int where row_id in
(select row_id from catalog_product_entity_int where attribute_id = 97 and value = 1) ,
(select row_id from catalog_product_entity_int where attribute_id = 99 and value = 4)) t
ON main_table.brand_id = t.value

是否可以在 WHERE IN 语句中添加多个 select 查询。

顺便说一句,在执行查询时我有 #1248 - 每个派生表都必须有自己的别名

最佳答案

我不太确定您的查询要做什么。但这似乎是编写逻辑的一种更简单的方法:

SELECT b.* 
FROM `prd_brand` AS b INNER JOIN
(SELECT DISTINCT value
FROM catalog_product_entity_int
WHERE (attribute_id, value) IN ( (97, 1), (99, 4) )
) t
ON b.brand_id = t.value

关于mysql - WHERE IN 语句中的多个选择查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44884661/

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