title: Joining Two Child Tables of a Single Parent, to retrieve the data - MySQL
body: <p>I have two child tables naming <code>imported_cables_entry</code> and <code>imported_cables_entry</code>, and a parent table called <code>cables_entry</code>. The two children have foreign keys columns called  <code>cables_id</code> pointing the primary key <code>id</code> of <code>cables_entry</code>.</p>
  
  <p>What I want to achieve is, to write a query, which retrieves all the data from parent matching the following conditions : </p>
  
  <p>if <code>imported_cables_entry</code>.<code>cables_id</code> = <code>cables_entry</code>.<code>id</code>
  if <code>local_cables_entry</code>.<code>cables_id</code> = <code>cables_entry</code>.<code>id</code></p>
  
  <p>Both of these conditions works fine, but retrieves  0 results. When they are executed one by one, then I get the proper results.</p>
  
  <blockquote>
    <p>Retrieve all the data from parent table, where the conditions for child tables meets. When the Unique <code>id</code> of the parent and the <code>cables_id</code> of the children matches with either conditions.</p>
  </blockquote>
  
  <p><strong>Query</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>SELECT `cables_entry`.*, `imported_cables_entry`.*, `local_cables_entry`.* 
   FROM `cables_entry`
  JOIN `imported_cables_entry` 
   ON `imported_cables_entry`.`cables_id` = `cables_entry`.`id` 
  JOIN `local_cables_entry` 
   ON `local_cables_entry`.`cables_id` = `cables_entry`.`id`</code></pre>
  </div>
  </div>
  </p>