title: How to select from two columns in different tables conditionally
body: <p>I have two tables</p>
  
  <pre><code>1. products &lt;id, taxon, .... &gt;
  2. tags &lt;id, tag_name, product_id, value, ....&gt;
  </code></pre>
  
  <p>I want to join (or do some other operation) on these two tables to get taxon but based on the value of a particular tag_name. Let me make it more clear, if a product has tag with <code>tag_name=type</code> and <code>value=precious</code>, I want to treat this tag value as a taxon.</p>
  
  <p>So if I have following entries:</p>
  
  <pre><code>&lt;# product id:1, taxon:"Jewellery"&gt;
  &lt;# product id:2, taxon:"Apparel"&gt;
  &lt;tag id:1, tag_name:"type", product_id:1, value="Precious"&gt;
  </code></pre>
  
  <p>I want the following in the result table</p>
  
  <pre><code>product_id   taxon_name
      1        Jewellery
      1        Precious
      2        Apparel
  </code></pre>
  
  <p>How can I form such a query?</p>
  
  <p>Thanks</p>