I have a query which loads data into a temporary table
SELECT * INTO #tempTable FROM Players where [reference month] = '2016-08-01'
I now need to use these ID's to find them in the previous month
SELECT ID FROM Players WHERE [reference month] = '2016-07-01' AND EXISTS
(SELECT #tempTable.ID FROM #tempTable)
I have tested the #tempTable (SELECT * FROM #tempTable) which returns 346 records which is correct.
The above code is searching every record (1000+) in the Players table and not the specific ID's that are found in the #tempTable
How can I fix this query to only use the ID's found in the #tempTable?