Received: from as.tksoft.com (gyw.com [209.55.67.177] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id QAA58651 for ; Thu, 6 Apr 2000 16:19:21 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: (from tjk@tksoft.com) by uno.tksoft.com (8.8.8/8.8.8) id NAA22377; Thu, 6 Apr 2000 13:18:40 -0700 From: "tjk@tksoft.com" Message-Id: <200004062018.NAA22377@uno.tksoft.com> Subject: Re: update only if single row To: fbax@execulink.com (Frank Bax) Date: Thu, 6 Apr 2000 13:18:40 -0700 (PDT) Cc: pgsql-sql@postgresql.org In-Reply-To: <3.0.6.32.20000406132216.008a8420@execulink.com> from "Frank Bax" at Apr 6, 0 01:22:16 pm Content-Type: text X-Archive-Number: 200004/56 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 >