title: Mysqli query to retrieve parent details along with multiple children details from separate table
body: <p>I have a site to manage property and it also stores the owners details. On the main page i need to retrieve the owners details. At the moment i am performing two separate queries, and a few different functions but i know there is a better way by streamlining it all into one query. </p>
  
  <p>So i have set out to learn some more about JOIN, i have come to a point were i need a little help.</p>
  
  <p>My query at the moment works fine if there is only one owner to retrieve. It grabs all the property data and the owner details. But in some cases there will be two owners, in the case that i have two owners listed it will retrieve all the property data and one owner, and then again all the property data and the second owner.</p>
  
  <p>So i need to refactor my query to retrieve perhaps the first owner as owner_name1 = etc, and if a second owner present owner_name2 = etc.</p>
  
  <p>Currently all the property data is stored in a table called 'property' and the owner details are stored in a table called 'owner'.</p>
  
  <p>Here is my current query and the results.</p>
  
  <pre><code>    QUERY:
  
          $result = $connection-&gt;query("
          SELECT property.*,owner.*
          FROM property
          INNER JOIN owner
          ON property.property_id = owner.property_id
          WHERE property.property_id='$id'
  
      ") ;
  
  
   RESULTS:
  
   Array
   (
       [property_id] =&gt; 52
       [property_created] =&gt; 2014-08-04 11:45:53
       [property_edited] =&gt; 2014-08-16 12:41:08
       [property_lot_no] =&gt; 111
       [property_house_no] =&gt; 44
       [property_street] =&gt; Hereford Way
       [property_suburb] =&gt; Picton
       [property_state] =&gt; NSW
       [property_postcode] =&gt; 2570
       [property_cross_street] =&gt; Friesian Way
       [property_lat] =&gt; -34.157500
       [property_lng] =&gt; 150.611436
       [owner_id] =&gt; 180
       [owner_name] =&gt; Ms D Bokody
       [owner_email] =&gt; 
       [owner_mobile] =&gt; 555
       [owner_phone] =&gt; 
   )
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/28Akv.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/KAwFv.png" alt="enter image description here"></p>
  
  <p>Thanks for checking it out.</p>
  
  <p>Ryann,</p>