unexperienced mysql user here 🙂
I have 2 tables
One holds a list of events created by users. It also has a description of the event.
The other table holds the date(s) for the event. It also has the unique id for the event. One event can have multiple dates associated with it.
My problem:
I wish to return a list with the events and the description. Right now I use a for each loop for this.
Example:
[loop]
$list .= '<tr><td>$date</td><td>$description</td><tr>';
[/loop]
return $list;
Now I need to show events with the same date as one event but combining the descriptions
Example:
$list .= '
<tr>
<td>two-events-with-same-dates-here-but-shown-as-one</td>
<td>$description 1<br />$description 2</td>
</tr>
';
return $list;
So my idea was to group by date and run a loop for each group with a new query and combine the descriptions into one description.
Running new queries in loops sound wrong and inefficient to me a I figured mysql has some smart build-in functions for something like this.
Ideas?
what about sorting the result by date, and then add < br/ > in php until the date has changed?
another solution is to use group_concat. example:
this will procuce