DELETE FROM `category`
 WHERE `category`.`category_id` NOT IN (
    SELECT `category_id`
      FROM `post`
     GROUP BY `post`.`category_id`
    HAVING COUNT(`post`.`post_id`) > 0 );