how to constrain a query to return 1 or 0 rows (or >1 or 0 rows)

From: Kevin Murphy <murphy(at)genome(dot)chop(dot)edu>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: how to constrain a query to return 1 or 0 rows (or >1 or 0 rows)
Date: 2004-09-10 21:39:31
Message-ID: E6652904-0371-11D9-B8EF-0003930D3626@genome.chop.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This is probably a stupid question, but ...

I'd like to be able to take an existing query and modify it to return a
single row if that's what the base query returns, and 0 rows if the
base query returns multiple rows. Similarly, I'd like to also modify
it to return multiple rows if that's what the base query returns, and 0
rows if the base query return a single row.

What's a good way to do this?

Thanks,
Kevin Murphy

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2004-09-10 21:42:16 Re: 8.0.0beta2: gcc: unrecognized option `-pthreads'
Previous Message Dan Sugalski 2004-09-10 21:23:37 Re: Speeding up LIKE with placeholders?