title: Mysql query - Showing a second taxonomy for a product stopped me
body: <p>I am in the situation where I need of the following information:</p>
  
  <ol>
  <li>ID       (posts.ID)</li>
  <li>TITLE    (posts.title)</li>
  <li>SKU      (postmeta.metakey = ‘_sku’) --> value stored in (postmeta.metavalue)</li>
  <li>PRICE    (postmeta.metakey= ‘regular_price’) -> value stored in (postmeta.metavalue)</li>
  <li>BRAND    (terms.name WHERE term_taxonomy_term.taxonomy=‘product_cat’)</li>
  <li>CATEGORY (terms.name WHERE term_taxonomy_term.taxonomy=‘brand’)</li>
  </ol>
  
  <p><code>SKU</code> and <code>PRICE</code> belongs to the same column "postemeta.metakey" which related values are in the "postemeta.metavalue".</p>
  
  <p><code>BRAND</code> and <code>CATEGORY</code> belongs to the same column "terms.name" but they have different taxonomies defined in "term_taxonomy.taxonomy" and are ('product_brand' and 'product_cat').</p>
  
  <p>Developing the query below I was able to collect all the information except for one that is the <code>BRAND</code> (terms.name).</p>
  
  <pre><code>   SELECT p.ID
            , MAX(CASE WHEN pm1.meta_key = '_sku' 
                       THEN pm1.meta_value 
                       ELSE NULL END) AS sku
            , p.post_title
            , t.name AS product_category
            , MAX(CASE WHEN pm1.meta_key = '_price' 
                       THEN pm1.meta_value 
                       ELSE NULL END) AS price
       FROM mg_posts p 
  LEFT JOIN mg_postmeta AS pm1 
         ON pm1.post_id = p.ID
  LEFT JOIN mg_term_relationships AS tr 
         ON tr.object_id = p.ID
       JOIN mg_term_taxonomy AS tt 
         ON tt.taxonomy = 'product_cat' AND tt.term_taxonomy_id = tr.term_taxonomy_id 
       JOIN mg_terms AS t 
         ON t.term_id = tt.term_id
      WHERE p.post_type IN ('product', 'product_variation') 
      GROUP BY p.ID, p.post_title
  </code></pre>
  
  <p>Any help to fix this issue??</p>