I’ve got a table for helping choose products.
I would like to have a query where I got back every record where:
category_id = 'M10' and band_id = '010'
OR
category_id = 'M10' and band_id = '020'
AND
category_id = 'M50' and band_id = '010'
OR
category_id = 'M50' and band_id = '020'
My query:
SELECT
product.entry_id AS entry_id,
helpme.item_id AS product_id
FROM inbound_help_me_choose helpme
LEFT JOIN exp_channel_titles product ON (product.product_id = helpme.item_id)
WHERE
helpme.submarket_id = 'NZ'
AND
(
(helpme.category_id = 'M10' AND helpme.band_id = '010')
OR
(helpme.category_id = 'M10' AND helpme.band_id = '020')
)
works fine on the first category, but as soon I’m adding new WHERE conditions are failing:
SELECT
product.entry_id AS entry_id,
helpme.item_id AS product_id
FROM inbound_help_me_choose helpme
LEFT JOIN exp_channel_titles product ON (product.product_id = helpme.item_id)
WHERE
helpme.submarket_id = 'NZ'
AND
(
(helpme.category_id = 'M10' AND helpme.band_id = '010')
OR
(helpme.category_id = 'M10' AND helpme.band_id = '020')
)
AND
(
(helpme.category_id = 'M50' AND helpme.band_id = '010')
OR
(helpme.category_id = 'M50' AND helpme.band_id = '020')
OR
(helpme.category_id = 'M50' AND helpme.band_id = '030')
)
It seems OK for me, so I completely lost why it’s not working.
I think you need this