Any other ways of doing same? [message #58535] |
Mon, 15 September 2003 20:11 |
Kapil
Messages: 145 Registered: May 2002
|
Senior Member |
|
|
I have 2 tables, tab1 and tab2 both have ID
as the fields, in tab1 ID is not unique and has 225097
rows, and in tab 2 ID is unique and has 1392684 rows,
i want see if there is any id that is present in tab1
but not in tab2.
Well I am doing this but it takes for ever. actually never give me the out put.
1. select id from tab1 where id not in(select id from tab2);
2. select id from tab1 where not exists(select id from tab2 where tab2.id=tab1.id);
none of these queries works, i mean fast. i do have indexes on id on both the tables. is there any other way of doing same thing ?
|
|
|
Re: Any other ways of doing same? [message #58536 is a reply to message #58535] |
Mon, 15 September 2003 21:06 |
Nihal
Messages: 1 Registered: September 2003
|
Junior Member |
|
|
This will definitly be faster, I have used this in some of my queries with good result, Perform a outer join and filter the recs
For ef
select id from
tab1 a , tab2 b
where a.id = b.id (+)
and a.id is not null
and b.id is null
This will give u the id which is present in table a and not present in table b
I'll be interested in knowing how it goes,
Cheers
Nihal Singh
|
|
|
|
|
|
|
|