There are two posts Post121 and Post122 , which Test1 into the category Test1 subcategory Test12

There is a wp_post table:

  ID | post_title | post_name | 157 | Post121 | post121 | 159 | Post122 | post122 | 

Table wp_term_relationships :

 object_id | term_taxonomy_id | 1 | 1 | 157 | 4 | 159 | 4 | 

Table wp_term_taxonomy :

  term_taxonomy_id | term_id | 2 | 2 | 3 | 3 | 4 | 4 | 5 | 5 | 

wp_terms table:

  term_id | name | 2 | Test1 | 3 | Test11 | 4 | Test12 | 

you need to make a sample to get it:

  PostTitle | CategoryTitle | Post121 | Test12 | Post122 | Test12 | 
  • Join Joy and again Join - teran
  • can you do? - Vasil Tkachuk
  • one
    reached SELECT wp_posts . post_title , wp_terms . name FROM wp_posts INNER JOIN wp_term_relationships ON wp_posts . ID = wp_term_relationships . object_id INNER JOIN wp_term_taxonomy ON wp_term_relationships . term_taxonomy_id = wp_term_taxonomy . term_taxonomy_id INNER JOIN wp_terms ON wp_term_taxonomy . term_id = wp_terms . term_id - Vasil Tkachuk

1 answer 1

 SELECT p.post_title AS PostTitle, t.name AS CategoryTitle FROM wp_post AS p JOIN wp_term_relationships AS tr ON p.ID = tr.object_id JOIN wp_term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id JOIN wp_terms AS t ON t.term_id = tt.term_id 

Something like this. Perhaps the error crept in - check on a live database ...