SELECT product_id FROM(
SELECT DISTINCT p.product_id, pd.name, p.model, p.quantity, p.price, p.sort_order, p.date_added , p.price as realprice
FROM oc_product p
LEFT JOIN oc_product_option_value pov ON (pov.product_id=p.product_id)
LEFT JOIN oc_product_description pd ON (pd.product_id=p.product_id)
LEFT JOIN oc_product_to_store p2s ON (p2s.product_id=p.product_id)
LEFT JOIN oc_product_to_category p2c ON (p2c.product_id=p.product_id)
LEFT JOIN oc_category_path cp ON(cp.category_id=p2c.category_id)
LEFT JOIN oc_product_attribute p2a ON (p2a.product_id=p.product_id)
LEFT JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p2a.product_id)
LEFT JOIN oc_product_attribute p2a1 ON (p2a1.product_id=p2a.product_id)
LEFT JOIN oc_product_attribute p2a2 ON (p2a2.product_id=p2a.product_id)
LEFT JOIN oc_product_attribute p2a3 ON (p2a3.product_id=p2a.product_id)
LEFT JOIN oc_product_attribute p2a4 ON (p2a4.product_id=p2a.product_id)
LEFT JOIN oc_product_attribute p2a5 ON (p2a5.product_id=p2a.product_id)
WHERE 1 AND cp.path_id IN (3558)
AND p2a0.attribute_id = 12 AND (p2a0.text LIKE '%ЛПО%')
AND p2a1.attribute_id = 20 AND (p2a1.text LIKE '%2х36 Вт%')
AND p2a2.attribute_id = 22 AND (p2a2.text LIKE '%накладные%')
AND p2a3.attribute_id = 27 AND (p2a3.text LIKE '%60 см%')
AND p2a4.attribute_id = 29 AND (p2a4.text LIKE '%T8%')
AND p2a5.attribute_id = 30 AND (p2a5.text LIKE '%220 В%')
AND pd.language_id = '1' AND p.status = '1' AND p2s.store_id = 0) as innertable
WHERE 1 ORDER BY sort_order ASC, LCASE(name) ASC LIMIT 0,20
and exists (select *
from oc_product_attribute a
where a.product_id=p2a.product_id
and a.attribute_id = 12
and a.text LIKE '%ЛПО%'
)
LEFT JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p2a.product_id)
JOIN oc_product_attribute p2a0 ON (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')
select product_id from oc_product_attribute p2a0 where (p2a0.product_id=p.product_id and p2a0.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%')
select * from oc_product where product_id IN (1,2,3 ...)
SELECT product_id FROM(
SELECT DISTINCT p.product_id, pd.name, p.model, p.quantity, p.price, p.sort_order, p.date_added , p.price as realprice
FROM oc_product p
LEFT JOIN oc_product_option_value pov ON pov.product_id = p.product_id
LEFT JOIN oc_product_description pd ON pd.product_id = p.product_id
LEFT JOIN oc_product_to_store p2s ON p2s.product_id = p.product_id
LEFT JOIN oc_product_to_category p2c ON p2c.product_id = p.product_id
LEFT JOIN oc_category_path cp ON cp.category_id = p2c.category_id
LEFT JOIN oc_product_attribute p2 ON p2.product_id = p.product_id
WHERE 1 AND cp.path_id IN (3558)
AND (
(p2.attribute_id = 12 AND p2a0.text LIKE '%ЛПО%') OR
(p2a1.attribute_id = 20 AND p2a1.text LIKE '%2х36 Вт%') OR
(p2a2.attribute_id = 22 AND p2a2.text LIKE '%накладны%') OR
(p2a3.attribute_id = 27 AND p2a3.text LIKE '%60 см%') OR
(p2a4.attribute_id = 29 AND p2a4.text LIKE '%T8%') OR
(p2a5.attribute_id = 30 AND p2a5.text LIKE '%220 В%')
)
AND pd.language_id = '1' AND p.status = '1' AND p2s.store_id = 0) as innertable
WHERE 1 ORDER BY sort_order ASC, LCASE(name) ASC LIMIT 0,20