title: Wordpress Custom SQL Query and Group Concat
body: <p>I am trying to run the below query to get the unique result of object_id.  I figured using Group_concat Distinst might work the best. I need to used the results of the query as a variable in the where clause of my next query.</p>
  
  <p>The below query runs fine in flyspeedsql software, but I can't seem to see the results in php.</p>
  
  <p>Is there a better way to approach this?</p>
  
  <p>Is wordpress get_results the right function to use?</p>
  
  <p>It should return something link 55,56,57</p>
  
  <p>Also from the results of this query how do I set up a variable that could be used in the  where clause of my next query?</p>
  
  <p>Query 1</p>
  
  <pre><code>      $query = ("Select
           Group_Concat(Distinct $wpdb-&gt;term_relationships.object_id)
        From
             $wpdb-&gt;term_taxonomy Inner Join
             $wpdb-&gt;term_relationships On $wpdb-&gt;term_taxonomy.term_taxonomy_id =
             $wpdb-&gt;term_relationships.term_taxonomy_id Inner Join
             $wpdb-&gt;terms On $wpdb-&gt;term_taxonomy.term_id = $wpdb-&gt;terms.term_id
         Where
             $wpdb-&gt;terms.name = 'Honda' And
             $wpdb-&gt;term_taxonomy.taxonomy = 'brands'");
  
         $results = $wpdb-&gt;get_results($query);
  </code></pre>