I have a mysql database with 3 tables, one table is called fixturechannels, one is called footballfixtures, and one is called satellite.
Basically the satellite table contains information about satellite channels (name, country, channelid), footballfixtures contains (matchid, hometeam, awayteam, competition....), and fixturechannels is a table containing (matchid, and channelid, these are linked by foriegn keys from the satellite and footballfixtures table respectively).
Below are further details on the tables:
I used the following query below, and it worked, I was able to echo the details I need from the table
"SELECT * FROM fixturechannels INNER JOIN footballfixtures ON fixturechannels.matchid=footballfixtures.matchid INNER JOIN satellite ON fixturechannels.channelid=satellite.channelid";
The code used for echoing the details is:
<tbody><tr>
<th>Match ID</th>
<th>Home Team</th>
<th>Away Team</th>
<th>Competition</th>
<th>Date</th>
<th>Time</th>
<th>Channel ID</th>
<th>Channel Name</th>
</tr>
<?php foreach ($results as $res) { ?>
<tr>
<td><?php echo $res["matchid"]; ?></td>
<td><?php echo $res["hometeam"]; ?></td>
<td><?php echo $res["awayteam"]; ?></td>
<td><?php echo $res["competition"]; ?></td>
<td><?php echo $res["date"]; ?></td>
<td><?php echo $res["time"]; ?></td>
<td><?php echo $res["channelid"]; ?></td>
<td><?php echo $res["name"]; ?></td>
</tr>
My issue is that the match details are displayed twice as there are two channels listed as showing the same match (see image)
my desired output is to have the details for each match to be shown once, and the names of multiple channels showing the matches to be displayed in the channel name column (no multiple rows)
I tried using GROUP_CONCAT, but didn't have success, I tried GROUP_CONCAT as I know it is not recommended to have multiple values per field in MYSQL.
Many Thanks to anyone who can provide assistance or guidance.
adding a group_by on HOME TEAM, AWAY TEAM and Competition along with GROUP_CONCAT of channels should work!