Something like this should work:
select t.name cat, p.name parent
from wp_terms t, wp_term_taxonomy tt, wp_terms p
where tt.term_id=t.term_id and tt.parent=p.term_id
(this only returns categories with a parent)
Related Posts:
- Deleting All tags except categories Wp database
- Modify WordPress SQL Query to pull from within a category
- batch adding posts to a category based on matching regex for title with SQL
- SQL to migrate post types to taxonomy
- Custom SQL Query: Get all posts with category id and a concated list of tags on each post
- Get posts under a category with SQL
- Get a count of how many times a term or a category is used in posts
- Overriding default calendar to show posts from a category
- SQL query to get posts from multiple categories but not in a category
- Assign a list of categories with a parent category
- Get category from slug list
- Bulk Change WordPress category Slug
- Help with SQL query, how to add taxonomie terms with value stored in options?
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Get page content by category or tag
- Using categories & “stickyness” together
- Changing the category permalink structure
- Moving Categories submenu to Media, but still opens Posts menu
- How to query all posts of a specific category, and any other category combination
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Page with the same name of a category
- How to make category RSS feeds show full content
- How to Check if a Child Category is Being Queried
- Creating Pages that show specific blog categories [closed]
- If a post belongs to two categories how do I choose the main category?
- Change post category based on latest posts views
- Attachment page per category
- How to get the depth of a category’s subcategories
- Best way to programmatically link to multiple categories (union/intersection) [closed]
- Code to pull in a PHP file named after the category ID
- in_category() works in single.php but not in page.php?
- functions.php conditional tag – only show in single.php?
- How do I create a way for users to assign categories to a post from the frontend of the website?
- Get categories from save_post hook
- Need to pull parent category and slug – only pulling daughter category
- Display children of the category a post is assigned to
- Random post + categories + tags
- WordPress category page redirects in .htaccess not working
- WordPress admin categories sort show is wrong
- Displaying Categories and Sub Categories
- Change thumbnail image depending product category
- How to organize custom categories for filtering and selecting
- How to list categories within tags?
- get_next_post set the category
- Different menu navigation per category
- category doesn’t showing up in admin
- Get category URL knowing it’s id
- Change every post background based on category
- How could I know all the categories from post?
- How to make subcategory for custom post and and display?
- Create menu locations for each category in wordpress
- Get category’s parent category while using get_the_category_list
- How to make the ‘delete’ button inactive on some categories?
- wp_list_categories with show_count, except for specific categories
- Show the amount of posts in a tag in a specific category has
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- How do I add a category to my post_type
- Add posts of a certain category to a page
- Show 10 Sub Categories Per Parent Category Page?
- Conditional category & tag statement
- How to remove the category from post slug
- Post Loop Category first show parent then child
- How to display posts from specific category using get_option function?
- wp_nav_menu not appearing correctly on category page
- Post not found when filtered by category ID
- How to detect /category and /tag base pages?
- Display all posts from selected category
- Is there any better/faster code than this ? It shows the categories that an author had ever posted in
- How to show only child categories using the_category();
- Why in the e-mail notification about a new post published, the category of the post is always: Uncategorized
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Hide Some Categories in Post Editor
- Identify a single category and output some code on an archive page
- in post content shortcode works, but hardcoded in same page template doesn’t?
- Only 10 of 233 categories selectable when adding a new post
- When creating category, it creates automatically tag, or, when creating tag, it creates automatically category in same name
- Should I select only the last child product category?
- List posts from a category and embed them into a page
- How to echo Tags and Categories as plain text
- Get category of a taxonomy for a queries object in a loop
- Make related posts display first in search result
- Display sub categories of a parent product in products – woocommerce [closed]
- Loop within category’s posts
- WordPress edit.php category filter to show only posts from direct category and not posts from it child category
- How can I just show portfolio items from 1 category on portfolio page?
- How to add a new child category via an SQL statement?
- Several loop in search result
- Link categories to last post
- wp_list_categories not working on my live site
- Recent posts in current category?
- add an image field to wordpress category
- How to display a linked category name with get_the_category
- Not able to display category link and name [closed]
- How to display category list with category description
- how do i set an image for a category in admin panel
- Issue on Listing Sub Product Categories In Woocommerce
- How to retrieve posts from parent category, splitting them per children when displayed?
- Display Product category in archive product page
- How to link images of one WP site to another WP site?
- Categories and products woocommerce wordpress