Jump to content

Results by querying two different datatables....


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'

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.