title: SQL Query to fetch record from 1 tables based on 2 records in the table
body: <p>I have to write a query which will display the top 25 game_id which are under specific genre.
  Database table is like</p>
  
  <pre><code>| id | genre_id | game_id | is_primary |
  ----------------------------------------
    1    6000       12345      0
    2    6007       12345      1
    3    6000       23492      0
    4    6007       82837      1
  ----------------------------------------
  </code></pre>
  
  <p>Here you can see that record 1 and 2 have same game_id for both is_primary = 0 and 1. What i have to do is to execute a query having both the genre_id with me and i have to fetch the game_id which falls under both. Means game_id which have 6000 as genre_id and is_primary=0 and 6007 as genre_id with is_primary=1.</p>
  
  <p>Searched on net but no success.</p>
  
  <p>I tried this query</p>
  
  <pre><code> SELECT game_id FROM table_name WHERE 
  (SELECT game_id FROM table_name WHERE genre_id=6000 AND is_primary=0) 
  AND ganre_id=6007 AND is_primary=1;
  </code></pre>
  
  <p>But this query is giving error as <code>Subquery returns more than one value</code>.</p>