I currently have an SQL statement to fill a table with a student name and the name of a sport which they are taking in a given term. The name of the sport is stored in a sports table with a Sport_ID. The Sport_ID then corresponds with a Choice_ID in the choices table. This Choice_ID is then put in the column for each term labelled T1_Choice, T2_Choice and T3_Choice in the table Student_Choices. How would I get T2_Choice and T3_Choice from my SQL statement? Thanks for the help.
$stmt = $conn->prepare(
"SELECT st.Name AS student, s.Name AS sport
From Sports AS s INNER JOIN Choices AS c
ON s.Sport_ID = c.Sport_ID INNER JOIN Student_Choices AS sc
ON sc.T1_Choice = c.Choice_ID INNER JOIN Students AS st
ON st.Username = sc.Username
");
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>
<td>'.$row['student'].'</td>
<td>'.$row['sport'].'</td>
<td>'.$row['sport'].'</td>
<td>'.$row['sport'].'</td>
</tr>
';
}