Jump to content

Results by querying two different datatables....


Jim R

Recommended Posts

I can't seem to wrap it around my head how to get a desired result from querying two tables.  I get two or multiple columns but not when it involves two tables.

 

It's a WordPress query.  I'm trying to:

 

SELECT name FROM wp_terms WHERE (this is where I stumble)...

 

where  taxonomy from wp_term_taxonomy = post_tag

AND

term_id from wp_term_taxonomy = term_id from wp_teams

 

That is the table structure as best as I can tell.  :D

 

The two tables are wp_term and wp_term_taxonomy. 

I'm trying to extract results from "name" in wp_term, where "taxonomy" in wp_term_taxonomy is post_tag, matching them by "term_id", which is in both tables.

That just prints all the term.  I'm trying to get the ones that just have post_tag as their taxonomy.  I tried this, but I get a syntax error.

 

SELECT wp_terms.name
FROM wp_terms
INNER JOIN wp_term_taxonomy USING (term_id)
WHERE wp_term_taxonomy.taxonomy IS (post_tag)

Continuing with this project, I need to alter a column in one table based on what it matches in the other. 

 

tables are:

wp_term_taxonomy_test

wp_term_taxonomy

 

UPDATE wp_term_taxonomy_test
SET wp_term_taxonomy_test.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
WHERE wp_term_taxonomy.term_id = wp_term_taxonomy_test.term_id

 

The error I'm getting is that  wp_term_taxonomy.term_id    doesn't exist.  However, it does exist.

 

Error Code : 1054

Unknown column 'wp_term_taxonomy.term_id' in 'where clause'

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.