Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subselect returns incorrect values?

Status
Not open for further replies.

alebu

Programmer
Sep 7, 2002
46
Hi everyone. I got some problem with subselect, can't understand, why is so happens.
I divided original request in two parst.

First part:
sql: SELECT login FROM users WHERE restricted IS NULL;
returns: alpha, test, mem_user1, mem_usr2.

Second part:
sql: SELECT DISTINCT login FROM companies;
returns: alpha, test.

in this case, request like:
SELECT login FROM users WHERE restricted IS NULL AND login NOT IN( select distinct login from companies );
should return: mem_user1, mem_usr2, but it returns nothing!
But when I changed request to:
SELECT login FROM users WHERE restricted IS NULL AND login NOT IN( 'test', 'alpha' );
result was correct( i got mem_user1, mem_usr2 ).
Who knows, why it so?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top