I have one mysql table called ‘games’ with the fields: id, team1, team2, and date. I have a second mysql table called ‘teams’ with the fields: id, name, grade.
My goal is to select all ‘games’ with date = March 1st, but then ALSO where grade = 10th.
So I imagine I need some kind of subquery but I don’t know sql well enough. Any help appreciated.
All I know to do so far is:
("SELECT * FROM games WHERE date = '2012-03-01'")
Thanks so much. Also I do want a single sql statement…
I’m assuming
games.team1is related toteams.id, as isgames.team2.You just have to bring your
teamstable into the query with aJOIN.Since you have two columns in
gamesthat are related toteamsby theteams.idcolumn, you have to use two joins:I’ve specified that both teams be in grade 10, but you could change that to an OR if you wanted at least one of the teams being in grade 10. (say there was a game with a grade 12 team vs a grade 10 team).