title: How To Search Two Mysql tables Using Ones Data
body: <p>I have tables like this</p>
  
  <p><strong>mainTable</strong></p>
  
  <pre><code>Id | name | country
  1  | John | 5
  2  | Bill | 7
  </code></pre>
  
  <p><strong>categoriesTable</strong></p>
  
  <pre><code>other_table_id | category
  1              | 6
  1              | 12
  </code></pre>
  
  <p>My question is how can I say </p>
  
  <pre><code>SELECT id FROM mainTable 
  WHERE country=5 
  AND WHERE categoriesTable order_table_id=[**THE ID I JUST GOT FROM THE FIRST TABLE**] &amp;&amp; category=6 || category=12
  </code></pre>
  
  <p>Then returns the number of records that match so in this case 1</p>
  
  <p>Thanks!</p>