I am curious -- why is the following not a viable option here?

 SELECT Count(*) FROM components WHERE category = 'natural';



On 11/4/06, Igor Tandetnik <[EMAIL PROTECTED]> wrote:
Rich Shepard <[EMAIL PROTECTED]> wrote:
>   I want the latter case. In other words, if there are no records
> where 'category = "natural"' nothing should be returned. It would be
> nice if there was a return value that told me explicitly "no records
> match the where".

You could write

select exists (select * from component where category='natural');

This produces a singleton result (single row, single column). The only
cell of this result contains integer 1 if there are indeed rows with
category='natural' 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 component where category='natural';

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

Igor Tandetnik


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




--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation https://edu.osgeo.org/
-------------------------------------------------------------------------------------------------------
collaborate, communicate, compete
====================================================

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

Reply via email to