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?
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?