-- Select columns from the joined tables SELECT t.term_id AS CategoryID, -- Select term_id from wp_terms as CategoryID tax.parent AS ParentCategoryID, -- Select parent from wp_term_taxonomy as ParentCategoryID t.name AS CategoryName, -- Select name from wp_terms as CategoryName t.slug AS CategorySlug -- Select slug from wp_terms as CategorySlug -- From the wp_term_taxonomy table FROM wp_term_taxonomy tax -- Join with the wp_terms table where the term_id matches INNER JOIN wp_terms t ON tax.term_id = t.term_id -- Only get rows where the taxonomy column is 'category' WHERE tax.taxonomy = 'category'