Reputation: 1128
I am trying to query a table of football data called 'Data' but I only wish to return data for a given 'DateKickOff'. The problem that I have is that the kick off date is stored in a different table called 'Match'. Both tables contain a column called MatchID so I am able to run this query:
SELECT MatchID FROM Match WHERE DateKickOff='10/08/2013'
to get a list of the MatchID's that I am interested in. I then wish to run this query:
SELECT * FROM Data
but return only results where the MatchID is present in the result of the first query. I would really appreciate if somebody could advise me on how to go about doing this. Thanks
Upvotes: 0
Views: 296
Reputation: 14460
You can do this by using sub-query as well
SELECT *
FROM Data
Where MatchID IN (SELECT MatchID FROM Match WHERE DateKickOff='10/08/2013')
Upvotes: 2
Reputation: 2857
try this:
SELECT d.* FROM Data d INNER JOIN Match m ON m.MatchID = d.MatchID
WHERE DateKickOff = '10/08/2013'
Upvotes: 1