Re: What is bad in this query ? - Mailing list pgsql-sql

From Rod Taylor
Subject Re: What is bad in this query ?
Date
Msg-id 1051885971.94424.29.camel@jester
Whole thread Raw
In response to What is bad in this query ?  (Rado Petrik <r.p@szm.sk>)
List pgsql-sql
On Fri, 2003-05-02 at 09:21, Rado Petrik wrote:
> Hi,
>
> What is bad in this query ?
>
> SELECT CASE
>     WHEN EXIST(SELECT * FROM user WHERE name=rado)
>         THEN (INSERT INTO user VALUES('rado'))
>     END;

The INSERT is bad.

Try something like:
INSERT INTO user (name)SELECT name FROM user WHERE name = 'rado';


--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

pgsql-sql by date:

Previous
From: Achilleus Mantzios
Date:
Subject: Re: What is bad in this query ?
Next
From: Tom Lane
Date:
Subject: Re: timeofday() and now() issue..