Skip to content

Instantly share code, notes, and snippets.

@damour
Created June 18, 2013 15:23
Show Gist options
  • Select an option

  • Save damour/5806293 to your computer and use it in GitHub Desktop.

Select an option

Save damour/5806293 to your computer and use it in GitHub Desktop.
sql
SELECT COUNT(*)
FROM (
SELECT `pf`.`product_id`
FROM `products` `p`
JOIN `products_feature` `pf` ON p.product_id = pf.product_id
WHERE
p.`category_id` = 151 AND
(pf.feature_id=5 AND (`value` IN ('1600')))
OR
(pf.feature_id=6 AND `value` IN ('1024', '2048'))
GROUP BY `pf`.`product_id`
HAVING COUNT(pf.product_id) = 2
) AS X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment