我有一张桌子可以帮助选择产品。
我想查询我在哪里找回了每条记录:
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'
我的查询:
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')
)
在第一类上工作正常,但是一旦我添加新的 WHERE 条件失败:
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')
)
对我来说似乎没问题,所以我完全失去了为什么它不起作用。