Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Query that fetch whether any record exist

Re: Query that fetch whether any record exist

From: Remco Blaakmeer <remco_at_rd1936.quicknet.nl>
Date: 10 Jan 2000 00:06:06 GMT
Message-ID: <85b7pe$95k$1@rd1936.quicknet.nl>


In article <85ad31$jeh$1_at_news.netvision.net.il>,

        "Maoz Mussel" <maoz_at_mindcti.com> writes:
> What is the fastest method to check whether ANY record satesfy the
> WHERE clause? For example, the following query:
> SELECT COUNT (*) FROM tableX
> WHERE ...
> May require full table scan in order to return number of records with the
> specified criteria. Same with any MIN function usage, while all I want is
> a boolean value specifying whether any record exist, i.e. one that will
> stop execution once the first record is found.

SELECT 'yes, a record satisfies the WHERE clause' FROM dual
WHERE EXISTS ( SELECT 'x' FROM tablea WHERE ... )

The EXISTS clause will return TRUE at the first row returned from the subquery. No more than one row will be fetched from the subquery.

Remco
--
rd1936: 12:55am up 1 day, 5:34, 8 users, load average: 2.54, 2.33, 2.33 Received on Sun Jan 09 2000 - 18:06:06 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US