The Little Ninja (Ninjai)

“Select items from table one that dont exist in table two”Â
Maybe this SQL will be useful to someone:::Â
 I have been working on a website for a football team and become a little stuck with the SQL statements, I had two tables that I was using, Matches and Results.
 On the add results page I wanted to display all the current matches that had not been played, to check if a match had been played I wanted to check which match ID’s existed in Matches but not in Results:
This statement will select everything in table 1 with an ID that does not appear in table 2.
strSQL =”SELECT * FROM Table1 T1 LEFT OUTER JOIN Table2 T2 ON T1.id = T2.id WHERE T2.id IS NULL Order by date”This is the actual SQL used in my website:
strSQL =”SELECT * FROM Matches m LEFT OUTER JOIN results r ON m.id = r.id WHERE r.id IS NULL and m.team=’” & teamlist.selecteditem.value.tostring() & “‘ and m.season = ‘” & seasonID & “‘ Order by date asc”
As the site contains information for many teams and many seasons I needed to display data relevant to a certain team and season.