0

This question already has an answer here:

I have a custom query where I need a JOIN because I want to COUNT all the posts of a specific category.

So I checked the tables and I found out that table wp_term_relationships contains a reference to the wp_term_taxonomy table. The term_taxonomy_id.

However when I looked into the wp_term_taxonomy table again I found out that term_taxonomy_id and term_id are having the exact same values.

So are they always the same? Can I filter the results by category with only joining wp_term_relationships and using term_taxonomy_id?

marked as duplicate by TheDeadMedic, Mark Kaplun, Pieter Goosen, birgire, Robert hue Oct 15 '15 at 14:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

No, they are not the same.

It is quite clear looking at the table names:

term_id is the ID of a single term, whatever taxonomy it belongs to. The other information in the table term_taxonomy is related to the term - the slug, the title etc.

term_taxonomy_id is the ID of the relationship between a single term and a taxonomy, and does not contain any other data.

  • 1
    So why are they having the same values? And can I rely on those for getting posts by category? (Then I would have no need of joining the category table) – jave.web Feb 10 '14 at 12:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.