steveosoule
4/7/2015 - 10:58 PM

Miva - SQL Unassign Category Helper

Miva - SQL Unassign Category Helper

SELECT 
	c.code AS 'category_code',
    p.code AS 'product_code'
FROM s01_CategoryXProduct AS cxp
LEFT JOIN s01_Products AS p
ON cxp.product_id = p.id
JOIN s01_CategoryXProduct AS cxp2
ON cxp2.product_id = p.id
LEFT JOIN s01_Categories AS c
ON cxp2.cat_id = c.id
WHERE cxp.cat_id = (SELECT id FROM s01_Categories c WHERE c.code = 'discontinued') AND c.code != 'discontinued'