title: Custom wpdb query for select post more than one taxonomy
body: <p>I'm trying to write a custom select post query for wordpress. I'm using woocommerce. In woocommerce the default post type name is "product" and taxonomy name in "product_cat"
  I've added another taxonomy names "spec" for product specification.</p>
  
  <p>So in my product category assume "samsung", "laptop" is a term name for product category. and in "spec" I've some specification such as its "core i5 processor", "8gb ddr3 ram" etc. and my post title is "super notebook"</p>
  
  <p>I want to search it for any of this field like if type notebook in my search field it will show all notebook. Underneath the search input type text area I also have a select box which has all "product_cat" there like samsung, hp, apple, laptop etc.</p>
  
  <p><strong>Product title / Post title</strong></p>
  
  <ul>
  <li>Super notebook</li>
  </ul>
  
  <p><strong>product_cat</strong></p>
  
  <ul>
  <li>samsung</li>
  <li>laptop</li>
  </ul>
  
  <p><strong>spec</strong></p>
  
  <ul>
  <li>core i5 processor</li>
  <li><p>8gb ddr3 ram</p>
  
  <p>global $wpdb;</p>
  
  <pre><code>$query = "SELECT DISTINCT wp_posts.*
              FROM wp_posts, wp_term_relationships, wp_term_taxonomy, wp_terms
              WHERE (wp_terms.name LIKE '%ddr3 ram%'
                  OR wp_posts.post_title LIKE '%ddr3 ram%')
              AND wp_posts.post_status = 'publish'
              AND wp_posts.post_type = 'product'
              AND wp_posts.ID = wp_term_relationships.object_id
              AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
              AND wp_term_taxonomy.term_id = wp_terms.term_id  GROUP BY  wp_posts.ID ORDER BY wp_posts.post_title ASC";
  
  $object = $wpdb-&gt;get_results($query);
  
  _log($object);
  </code></pre></li>
  </ul>
  
  <p>I try this code it show the result.</p>
  
  <p>But if I try this it'll not show the result</p>
  
  <pre><code>global $wpdb;
  
      $query = "SELECT DISTINCT wp_posts.*
                  FROM wp_posts, wp_term_relationships, wp_term_taxonomy, wp_terms
                  WHERE (wp_terms.name LIKE '%ddr3 ram%'
                      AND wp_terms.name LIKE '%samsung%'
                      OR wp_posts.post_title LIKE '%ddr3 ram%')
                  AND wp_posts.post_status = 'publish'
                  AND wp_posts.post_type = 'product'
                  AND wp_posts.ID = wp_term_relationships.object_id
                  AND wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
                  AND wp_term_taxonomy.term_id = wp_terms.term_id  GROUP BY  wp_posts.ID ORDER BY wp_posts.post_title ASC";
  
      $object = $wpdb-&gt;get_results($query);
  
      _log($object);
  </code></pre>
  
  <p>I don't have any idea to fix this. So anyone want to help me please give this answer for me.
  Thanks.</p>