title: How to Select * FROM table1, table2 correctly when table1 = table2
body: <p>There is a table cs_goods_features like this
  (id - product id, f - product property name, v - property value)</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>f</th>
  <th>v</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>f1</td>
  <td>10</td>
  </tr>
  <tr>
  <td>1</td>
  <td>f2</td>
  <td>15</td>
  </tr>
  <tr>
  <td>1</td>
  <td>f3</td>
  <td>25</td>
  </tr>
  <tr>
  <td>2</td>
  <td>f1</td>
  <td>10</td>
  </tr>
  <tr>
  <td>2</td>
  <td>f2</td>
  <td>15</td>
  </tr>
  <tr>
  <td>2</td>
  <td>f3</td>
  <td>35</td>
  </tr>
  <tr>
  <td>3</td>
  <td>f1</td>
  <td>15</td>
  </tr>
  <tr>
  <td>3</td>
  <td>f2</td>
  <td>10</td>
  </tr>
  <tr>
  <td>3</td>
  <td>f3</td>
  <td>55</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need to select only those products id, which have, for example, f1 = 10 and f2 = 15.</p>
  <p>If I make a query like this</p>
  <pre><code>SELECT id 
    FROM cs_goods_features
    where (f in ('f1', 'f2'))
      and (v in (10,15))
  </code></pre>
  <p>then everything is fine except when the table has opposite values - not f1=10 and f2=15, but f1=15 and f2=10. I don't need such lines in result set.</p>
  <p>What I need can be done like this:</p>
  <pre><code>select g1.id, g2.id
     FROM cs_goods_features g1, cs_goods_features g2 
   WHERE g1.f = 'f1'
     and g1.v = 10 
     and g2.f = 'f2'
     and g2.v = 15
  </code></pre>
  <p>But the problem here is that I get two columns in the output (and if i need to select products by 3 properties - there would be 3 columns). And I'm not satisfied with it, because actually this query is going to be a subquery in a larger query.</p>
  <p>In other words there will be</p>
  <pre><code>SELECT * 
    FROM tablename
   where ID in (our_query)
  </code></pre>
  <p>It means I need exactly one column with results for construction &quot;where ID in (...)&quot; to work correctly</p>