SELECT DISTINCT p.products_image,
p.products_quantity,
m.manufacturers_id,
p.products_id,
pd.products_name,
p.products_price,
p.products_tax_class_id,
p.products_price_sorter,
p.products_qty_box_status,
p.master_categories_id
FROM products p
LEFT JOIN manufacturers m USING(manufacturers_id)
LEFT JOIN products_description pd ON p.products_id = pd.products_id
JOIN products_to_categories p2c ON p.products_id = p2c.products_id
JOIN categories c ON p2c.categories_id = c.categories_id
LEFT JOIN meta_tags_products_description mtpd ON mtpd.products_id= p2c.products_id
AND mtpd.language_id = 2
JOIN products_attributes p2a ON p.products_id = p2a.products_id
JOIN products_options po ON p2a.options_id = po.products_options_id
JOIN products_options_values pov ON p2a.options_values_id = pov.products_options_values_id
WHERE (p.products_status = 1
AND pd.language_id = 2
AND ((pd.products_name LIKE '%t%'
OR p.products_model LIKE '%t%'
OR m.manufacturers_name LIKE '%t%'
OR (mtpd.metatags_keywords LIKE '%t%'
AND mtpd.metatags_keywords !='')
OR (mtpd.metatags_description LIKE '%t%'
AND mtpd.metatags_description !='')
OR pd.products_description LIKE '%t%')))
GROUP BY p.products_id
HAVING sum(pov.products_options_id IN (12, 20)
AND pov.products_options_values_id IN (91,82)) > 0
ORDER BY p.products_sort_order,
pd.products_name;
答案 0 :(得分:0)
改变HAVING
<强>从强>
HAVING sum(pov.products_options_id IN (12, 20)
AND pov.products_options_values_id IN (91,82)) > 0
以强>
HAVING pov.products_options_id IN (12, 20)
AND pov.products_options_values_id IN (91,82)
为什么使用&gt; 0?你正在使用IN()