Skip to content

Instantly share code, notes, and snippets.

@iso100
Created September 27, 2012 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iso100/3795753 to your computer and use it in GitHub Desktop.
Save iso100/3795753 to your computer and use it in GitHub Desktop.
Filtering on multiple categories
SELECT count( cp.entry_id ) AS total_items,
cp.cat_id,
c.cat_name as category_name,
c.cat_url_title as category_url_title
FROM exp_weblog_titles AS wt
INNER JOIN exp_category_posts AS cp ON wt.entry_id = cp.entry_id
INNER JOIN exp_categories AS c ON cp.cat_id = c.cat_id
INNER JOIN exp_category_posts AS cp2 ON wt.entry_id = cp2.entry_id
INNER JOIN exp_categories AS c2 ON cp2.cat_id = c2.cat_id
WHERE wt.weblog_id = 57
AND wt.status != 'closed'
AND c.site_id = 8 AND c2.site_id = 8
AND c.group_id = 40 AND c2.cat_id = {segment_2_category_id}
GROUP BY c.cat_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment