tags:

views:

32

answers:

1

Hi, My SQL is a bit bad. I got a query that when I run it I return for example 10 rows but there are 15 in my where clause, how do I identify those 5 that I can't find?

Off course I can dump it in MS Excel but how do I use SQL?

Its a simple query:

select * from customers where username in ("21051", "21052"...

Nothing else in the where clause, it return 10 rows but there are 15 usernames in there where clause.

+1  A: 

To identify the missing rows:

SELECT * 
FROM (SELECT '21051' username 
      UNION ALL SELECT '21052'
      UNION ALL SELECT '21053'
      UNION ALL SELECT '21054') u 
WHERE u.username NOT IN (SELECT c.username FROM customers c) 
Anthony Faull
Unfortuneately, this is the way to to it... that or, make a temp table, and insert the items into that table and then do the same query.
Timothy Khouri