title: How to Retrieve data from Multiple Tables in MySQL single Query?
body: <p>I have a Database where the tables are as follows:</p>
  
  <p>Table Name: <code>userDB</code><br />
  Column Name: <code>user_id</code> (CUSTOMER'S ID), <code>reseller_id</code> (RESELLER WHO HAS SOLD CONNECTION TO CUSTOMER)</p>
  
  <p>Table Name: <code>serverDB</code><br />
  Column Name: <code>server_id</code> (SERVER'S ID) , <code>status</code> (UP OR DOWN STATUS - if 1 DOWN, if 0 UP)</p>
  
  <p>Table Name: <code>usageDB_january</code><br />
  Column Name: <code>user_id</code> (CUSTOMER'S ID) , <code>server_id</code> (SERVER'S ID)<br />
  ...<br />
  Table Name: <code>usageDB_december</code><br />
  Column Name: <code>user_id</code> (CUSTOMER'S ID) , <code>server_id</code> (SERVER'S ID)
  <br />NOTE: There are 12 tables from <code>usageDB_january</code> to <code>usageDB_december</code> for each month.</p>
  
  <p>In a PHP page I have listed the <code>server_id</code> which are DOWN (Status 1)</p>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__</strong><br />
  | SERIAL NO | ID of DOWN SERVERS |<br />
  | 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;28839              |<br />
  | 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;         | &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20283              |<br />
  <strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>_</strong><br /></p>
  
  <p>While I will click on ID of DOWN SERVERS I want to show the list of RESELLERS under that SERVER ID.</p>
  
  <p>I am not understanding that how to write the MySQL Query.</p>
  
  <p>Can you kindly help me? Please?</p>
  
  <p>I have no way to change the Database Table Structure. I am not understanding the query.</p>
  
  <p>SELECT <code>reseller_id</code>  <br >
  FROM <code>userDB</code>  <br >
  WHERE <code>user_id</code> = ( <br >
                  SELECT <code>user_id</code>  <br >
                  FROM <code>usageDB_january</code> <br >
                  WHERE <code>server_id</code> LIKE '17090' <br >
                  UNION <br >
                  SELECT <code>user_id</code>  <br >
                  FROM <code>usageDB_february</code> <br >
                  WHERE <code>server_id</code> LIKE '17090' <br >
              ); <br > <br ></p>
  
  <p>Error : #1242 - Subquery returns more than 1 row</p>