I have the following sql query :
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
Is that possible to add multiple select
queries in the WHERE IN
statement.
BTW, when executing the query I have #1248 - Every derived table must have its own alias
.
I'm not quite sure what your query is trying to do. But this seems like a simpler way to write the logic:
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