Need help with an SQL badge query

You can do this. The problem is that the query is using the badge_posts table. The badge_posts table doesn’t include posts from protected categories. If the query is changed to use the posts table instead of the badge_posts table, it should work.