Home » SQL & PL/SQL » SQL & PL/SQL » Verifying if the data(one row) fulfilling a select criteria exists in the table or not
Verifying if the data(one row) fulfilling a select criteria exists in the table or not [message #20581] Wed, 05 June 2002 20:23 Go to next message
eela
Messages: 7
Registered: June 2002
Junior Member
Hi,

Can some body suggest me a way for detecting if data exists in the table or not, I don't want to use
count(*) . Since count(*) gives total no of records for a query. I just want to know if a single record for that query existx or not. We have bulk of data and using count(*) for just knowing if the data exists or not, does not appear to be good approach.

thanks
Re: Verifying if the data(one row) fulfilling a select criteria exists in the table or not [message #20584 is a reply to message #20581] Wed, 05 June 2002 21:32 Go to previous messageGo to next message
manish mendiratta
Messages: 110
Registered: May 2002
Senior Member
You can use select count(*) from
where rownum < 2;

This will give you 1 is there exists a single record also. This is faster than count(*).

Hope this will help.

Regds
ManishM.
Re: Verifying if the data(one row) fulfilling a select criteria exists in the table or not [message #20596 is a reply to message #20581] Thu, 06 June 2002 03:38 Go to previous message
shyampaliyath
Messages: 22
Registered: May 2002
Junior Member
hai Eela,
using rownum is not a proper way becoz it may tend to return inconsitent data u have to use rowid.

select * FROM table_name a
WHERE rowid > ( SELECT min(rowid)
FROM table_name b
WHERE b.pk_column_1 = a.pk_column_1
and b.pk_column_2 = a.pk_column_2 );

with regards
Shyam
Previous Topic: stoping of a procedure
Next Topic: I need a SQL-Statement or function
Goto Forum:
  


Current Time: Fri Apr 26 00:35:40 CDT 2024