I have 2 basic tables -- a main table containing master ID records and a related table containing a variable number of value references as shown below.
TABLE A: Main (one)
+----+-------------+
| ID | description |
+----+-------------+
| 1 | Arnold |
+----+-------------+
| 3 | Baker |
+----+-------------+
| 7 | Charlie |
+----+-------------+
TABLE B: Related (Many)
+----+-------+
| ID | value |
+----+-------+
| 1 | 1 |
+----+-------+
| 1 | 2 |
+----+-------+
| 3 | 3 |
+----+-------+
| 3 | 2 |
+----+-------+
| 3 | 1 |
+----+-------+
| 7 | 2 |
+----+-------+
After joining Table A with Table B, is it possible to return the columns in such a way that the value column from Table B returns as an array?
I am looking to return something like the result set below (based on example above) where the 2nd column can be handled as an array value rather than a string value:
{
[0] => 1
[1] => array(1,2)
}
{
[0] => 3
[1] => array(3,2,1)
}
{
[0] => 7
[1] => array(2)
}
Here is my Query Statement to get the columns as string values:
SELECT tablea.*, tableb.value
FROM tablea
LEFT JOIN tableb ON tableb.ID = tablea.ID