Forum Moderators: open
If allowed, I'm going to borrow the tables from this MySQL Join page I've been using as a tutorial: [tizag.com...]
family Table:
Position Age
Dad 41
Mom 45
Daughter 17
Dog
food Table:
Meal Position
Steak Dad
Salad Mom
Tacos Dad
You will get the following output with this command:
$result=mysql_query("SELECT * FROM family, food WHERE family.position=food.position ORDER BY family.position DESC");
while($data=mysql_fetch_array($result)) echo "<li>".$data["family.position"]." - ".$data["food.meal"]."</li>";
<li>Dad - Steak</li>
<li>Dad - Tacos</li>
<li>Mom - Salad</li>
I'm wondering however, if the corrisponding data in the food table can be stored as some kind of subarray, allowing me to output this kind of result:
<li>Dad - Steak, Tacos</li>
<li>Mom - Salad</li>
I've been trying to lookup information on the MySQL website and in books on campus, but I haven't found anything on this issue, which makes me wonder if I'm going in the wrong direction.
Thanks
The example uses a UDF, but you may be able to do it in a subquery. The bottom line is, it's probably easier to do it in code than SQL.