4

I have a list of 338 strings like the following:

013705
013707
013708
013709

How do I get all of those strings that do not exist in my table/column: tblclients.clientID?

I've tried the following:

SELECT clientID FROM tblclients WHERE clientID NOT IN (
000100,
000834,
001855,
etc...)

But that only returns values from my table that do not exist in my list of strings. I need the opposite: strings from my list, that do not exist in the table. I'm wondering if this is possible with SQL or if I need to use Excel in some way...?

FastTrack
  • 8,630
  • 14
  • 56
  • 77

1 Answers1

1

If the numbers that you are testing are in YourNumbers then you can run a query like this:

SELECT clientID 
FROM YourNumbers y
LEFT JOIN TblClients t ON y.clientID = t.clientID
WHERE clientID IS NULL
PM 77-1
  • 12,254
  • 20
  • 64
  • 106
  • The question states that the numbers are not in a table. – User15 Aug 10 '15 at 21:47
  • @User15 - I read it that OP wants to find numbers which are not in his main table. The numbers to compare have to be stored somewhere. My solution uses a temporary table for this purpose. – PM 77-1 Aug 10 '15 at 21:59