Are term_taxonomy_id and term_id the same?

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?

Topic join-tables wp-query wpdb categories Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.