SQLTeam.com | Weblogs | Forums

Including spreadsheet data into Exclusion criteria


#1

I am trying to import data from 4 columns in a spreadsheet, the Columns are (Last Name - First Name - ID - Code) and this spreadsheet has around 10k records. I want to add what is in this spreadsheet to the query I have below that uses the EXCEPT operator but I am not sure the best way to go about it.

Using the example I have filtered below for the name "Denise Test", at the end of the day I want everything that is in the spreadsheet to also be excluded from the results.

So before the spreadsheet lets say the 2nd query referencing table C has the following results for Denise Test

Last_Name First_Name ID Code
Test Denise 1 5
Test Denise 2 4

After adding the spreadsheet I want it to show this:

Last_Name First_Name ID Code
Test Denise 1 5
Test Denise 2 4
Test Denise 3 3

Here is the query as it stands now without the inclusion of the spreadsheet:

SELECT
ta.last_name,
ta.first_name,
tb.ID,
tb.code
FROM
TableA ta
INNER JOIN TableB tb
on ta.id = tb.id
WHERE
ta.first_name='Denise'
and ta.last_name='Test'
EXCEPT
SELECT
ta.last_name,
ta.first_name,
tc.ID,
tc.code
FROM
TableA ta
INNER JOIN TableC tc
on ta.ID = tc.ID
WHERE
ta.first_name='Denise'
and ta.last_name='Test';

Any thoughts or ideas at how best to approach this?


#2

Where is this spreadsheet ?