WordPress mysql code to find posts not associated with a category.
SELECT * FROM wp_posts p WHERE p.post_type = 'post' AND p.post_status = 'publish' AND NOT EXISTS ( SELECT * FROM wp_term_relationships rel JOIN wp_term_taxonomy tax ON tax.term_taxonomy_id = rel.term_taxonomy_id AND tax.taxonomy = 'category' JOIN wp_terms term ON term.term_id = tax.term_id WHERE p.ID = rel.object_id )