MySQL Forums
Forum List  »  Newbie

Constructing a multi-table query
Posted by: Paul Rothenberg
Date: October 24, 2014 10:13AM

Hi all,

Newbie here trying to wrap my head around multi-table queries. I wrote the following to try and do something (albeit I knew inefficiently), but it makes the browser hang. How can I get $post_id in one query?

$query = "SELECT term_id FROM wp_terms WHERE name = '" . $answer . "'";
$termid = $wpdb->get_results($query,ARRAY_A);
$termid = $termid['term_id'];

$query = "SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id = '" . $termid . "'";
$postid = $wpdb->get_results($query,ARRAY_A);
$postid = $postid['object_id'];

the_content($postid);

Options: ReplyQuote


Subject
Written By
Posted
Constructing a multi-table query
October 24, 2014 10:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.