From: tjk@tksoft.com <tjk@tksoft.com>
To: fbax@execulink.com
Cc: pgsql-sql@postgresql.org
Subject: Re: update only if single row
Date: Thu, 6 Apr 2000 13:18:40 -0700 (PDT)
Message-ID: <200004062018.NAA22377@uno.tksoft.com> (raw)
In-Reply-To: <3.0.6.32.20000406132216.008a8420@execulink.com>
Frank,
The best I can come up with is using a temp table.
Something like:
select email into temp dummytable from contact where email ~* 'rvro' group by email having count(*) = 1;
update contact set bounce = 1 where email in (select email from dummytable);
It's still two queries. One use of your query, though.
Other than this, I would need to resort to a function.
Cheers,
Troy
>
> Here's the way I do it now:
>
> select * from contact where email ~* 'rvro';
> if I get a single row in the result then I enter:
> update contact set bounce=1 where email ~* 'rvro';
>
> Can I combine this into a single SQL statement with the following
> requirements:
> 1) the update is only performed if a single row is selected
> 2) I only enter the selection string ('rvro' in this case) once in the
> command?
>
> Frank
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tjk@tksoft.com, fbax@execulink.com
Subject: Re: update only if single row
In-Reply-To: <200004062018.NAA22377@uno.tksoft.com>
References: <3.0.6.32.20000406132216.008a8420@execulink.com> <200004062018.NAA22377@uno.tksoft.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox