Subject | Query slow |
---|---|
Author | sivram_mail |
Post date | 2003-04-16T12:53:29Z |
Hello,
i have two tables .
table 1
id name no
table 2
id no
table 2's id field is referenced to table 1's id field .
now i want to retrieve the records from table 1 and no not in
table 2.
this is the query which is written:
-----------------------------------
select * from table1 where id not in
(select id from table2,table1 where table1.no=table2.no )
In this query , there is no join condition for primary key.
If i rearrange this query to
select * from table1 a where
a.id not in (select id from
table2 b where a.id=b.id and a.no=b.no)
Will it work fine????
And my dba is telling that don't use "ot in".
without "not in" how can i write this query??
Thanks in advance
Sivaraman
i have two tables .
table 1
id name no
table 2
id no
table 2's id field is referenced to table 1's id field .
now i want to retrieve the records from table 1 and no not in
table 2.
this is the query which is written:
-----------------------------------
select * from table1 where id not in
(select id from table2,table1 where table1.no=table2.no )
In this query , there is no join condition for primary key.
If i rearrange this query to
select * from table1 a where
a.id not in (select id from
table2 b where a.id=b.id and a.no=b.no)
Will it work fine????
And my dba is telling that don't use "ot in".
without "not in" how can i write this query??
Thanks in advance
Sivaraman