PHP and mysql how to use joins to get the desired result
<p>When using Mysql and Php,</p>

<p>I have always done single queries and then used foreach loops to build an array of results from mysql databases. What id like to find out is how to do this with mysql instead.</p>

<p>My question is simple but im not sure how to go about it.</p>

<p>Basically id like to join 2 or more tables and end up with something like this:</p>

<p>['match from table 1'][0,1,2,3,4]</p>

<p>where table 1 is the main table and 0,1,2,3,4 are the results from the join.
at the moment i keep getting results in this format when doing joins</p>

<p>['table1'][0]<br/>
['table1'][1]<br/>
['table1'][2]</p>

<p>Basically what is happening is that I have 2 tables,
Hotels and Rooms. When i join them i get the same hotel name with 1 room,
My next result is then the very same hotel name with the next room...</p>

<p>What id like is for each hotel to return 1 result with all the rooms packed into the array. I have never understood how to achieve this with only a mysql query.</p>

<p>Ps. I did my undergrad (but sql was always my weakest point)
I am now considering doing a short sql brush up online course over my December break. So if you would like to chip in and point me to a good one id appreciate that.</p>

<p>Thanks!</p>