I want to get categories that had NO post. Below is sql for getting category with post..
SELECT terms.term_id,terms.name,COUNT(post.ID) FROM wp_posts as post
JOIN wp_term_relationships as rel ON post.ID = rel.object_ID
JOIN wp_term_taxonomy as ttax ON rel.term_taxonomy_id = ttax.term_taxonomy_id
JOIN wp_terms as terms ON ttax.term_id = terms.term_id
WHERE ( ttax.taxonomy='category' AND post.post_type='post' AND post.post_status != 'revision') GROUP BY (terms.term_id)
But how to get catgeory with NO post? Thank you for your help.