title: Mysql query with and conditions
body: <p>I've two tables,</p>
  
  <p>table 1</p>
  
  <pre><code>userid  filter
  thiru   1
  thiru   2
  thiru   3
  raja    1
  raja    2
  </code></pre>
  
  <p>table 2</p>
  
  <pre><code>headline    filter1 filter2
  test          1       3
  test2         1       2
  </code></pre>
  
  <p>If I want to select the users applicable for filters.<br/>
  when i select test - thiru is applicable ( filter1 and filter2 ) matching<br/>
  when i select test2 - thiru and raja are applicable ( filter1 and filter2 ) matching.</p>
  
  <p>Basically the filters are with and condition.</p>
  
  <p>Here is the query that i tried:</p>
  
  <pre><code>select userid 
    from table1 
   where filter in (select filter1 
                      from table2 
                     where headline = 'test') 
     and filter in (select filter2 
                      from table2 
                     where headline = 'test'); 
  </code></pre>
  
  <p>Please give me the query for this.
  Thanks in advance.</p>