I have three tables in MySQL:
CUSTOMERS
+------------+--------------+
| customerId | customerName |
+------------+--------------+
PRODUCTS
+-----------+-------------+
| productId | productName |
+-----------+-------------+
RENTALS
+--------------+--------------+-----------------+
| rentalNumber | rentalAmount | rentalProductId |
+--------------+--------------+-----------------+
The Rentals table has various rows for one rentalNumber. I need to return a result in php like this:
RESULT
+--------------+--------------+----------------------------------+
| customerName | rentalNumber | rentalDetails |
+--------------+--------------+----------------------------------+
| Johnny | 20 | productName1 x productAmount1, |
| | | productName2 x productAmount 2, |
| | | productName3 x productAmount 3 |
+--------------+--------------+----------------------------------+
the rentalDetails bit may be a string, displayed in a HTML table.
While fiddling along I found the answer eventually:
But perhaps there's an even better way. This works for me though :)