Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: WHERE IN query
A copy of this was sent to Frank van Bortel <f.van.bortel_at_vnl.nl>
(if that email address didn't require changing)
On Thu, 22 Apr 1999 14:00:57 +0200, you wrote:
>Joerg Leute wrote:
>
>> Hi everybody
>>
>> Isn't it possible to extend a WHERE IN query over 2 columns - first column
>> is number and second is char) like
>>
>> SELECT * FROM TABLE1 WHERE (ID, NAME) IN (SELECT ID_2, NAME_2 FROM TABLE2)
>>
>
>No - how would I (or the rdbms) need to read this? Is this an AND or an OR -
>what about
>NULLS for ID or NAME?
>use the AND, OR and outer joins to resolve all that
Yes:
SQL> select ename from emp
2 where ( ename, empno ) in ( select ename, empno from emp
3 where ename like '%A%' )4 /
ENAME
it compares the tuples like it would in a join. Its an AND (ename=ename AND empno=empno) and NULLs are never equal (nor are they NOT equal) so the comparision fails. for example, in emp -- there is a null mgr so:
SQL> select ename from emp
2 where ( ename, mgr ) in ( select ename, mgr from emp );
ENAME
returns 13, not 14 rows since a null mgr is not equal nor not not equal for one of them....
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities
![]() |
![]() |