Home » RDBMS Server » Server Administration » alternate SQL without Exists clause
alternate SQL without Exists clause [message #371095] Fri, 25 August 2000 04:26 Go to next message
suriyan
Messages: 3
Registered: August 2000
Junior Member
select table1.field1
from table1
where NOT EXISTS (select table2.field1
from table2
where table2.field1 = table1.field1)

can anyone suggest an alternative..without Using IN/EXISTS Clauses, preferably without using SubQueries also.

Thanks
Re: alternate SQL without Exists clause [message #371102 is a reply to message #371095] Fri, 25 August 2000 15:17 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
by definition, you are running a Correlated Subquery which you have probably found out is slow.

Take a look at the MINUS operation, it's especially good for eliminating "not in" which is very similar to your "not exists". MIUNS is fast!
Re: alternate SQL without Exists clause [message #371106 is a reply to message #371095] Mon, 28 August 2000 00:38 Go to previous messageGo to next message
suriyan
Messages: 3
Registered: August 2000
Junior Member
i am trying to execute this SQL via an ODBC driver, the feature of this driver is very limited, i cannot write any Correlated Subqueries.

i need to rewrite this SQL, without any subqueries, is there anyother ALTERNATIVE Logic..
Re: alternate SQL without Exists clause - try me [message #371108 is a reply to message #371095] Mon, 28 August 2000 12:02 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
Try this one, you may have to play with the code a bit.

SELECT table1.field1
FROM table1, table2
WHERE table1.field1 = table2.field1 (+)
AND table2.field1 IS NULL
Re: alternate SQL without Exists clause - try me [message #371111 is a reply to message #371108] Tue, 29 August 2000 03:20 Go to previous messageGo to next message
suriyan
Messages: 3
Registered: August 2000
Junior Member
Still No success in finding an alternative
Re: alternate SQL without Exists clause [message #371434 is a reply to message #371095] Thu, 19 October 2000 00:55 Go to previous message
umphy
Messages: 1
Registered: October 2000
Junior Member
select table1.field1
from table1, table2
where table2.field1 != table1.field1;
Previous Topic: PL\SQL: Procedure can't be created through SQL*PLUS 'cause it's too long
Next Topic: Re: Finding maximum 3 rows
Goto Forum:
  


Current Time: Sat Apr 27 00:04:06 CDT 2024