EllisLab text mark

This is an archived forum and may no longer be relevant. The active forums are here.

Advanced Search
Tweak Categories SQL Query to Only Show Child Categories w/ Entries?
Posted: 03 January 2011 09:15 PM
Joined: 2009-07-21
74 posts

I’m using the following tidbit from the WIKI site for displaying child categories of a parent category. Works great.

{exp:query sql="SELECT cat_url_title as category_url_title, cat_name AS category_name FROM exp_categories WHERE parent_id = '15'"}
<li><a href="http://{path=channel/category/{category_url_title}}/">{category_name}</a></li>
{/exp:query}

How do I tweak the query to only show child categories with entries in them?

Thanks for your help!