On Wed, 13 Dec 2006, RB Smissaert wrote:

Trying to find the fastest way to determine if a table has no rows.

I think this will do:
SELECT (SELECT ROWID FROM table limit 1) IS NOT NULL;
If a table has rows then the result should be 1.

RBS

  About a month ago, I sought a better solution than what I had devised.
Here's one of the answers for you:

You could write

select exists (select * from <table> where <fieldname>='<something>');

This produces a singleton result (single row, single column). The only cell
of this result contains integer 1 if there are indeed rows with
<fieldname>='<something>' in table component, and 0 if there are none.

I still don't understand why you want to "look before you leap", so to
speak. Why not just run the query

select * from <table> where <fieldname>='<something>';

and handle the case where it produces an empty result set?


Rich

--
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to