From: | lynch(at)lscorp(dot)com (Richard Lynch) |
---|---|
To: | Joao Paulo Felix <felix(at)cyclades(dot)com>, "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org> |
Subject: | Re: [GENERAL] Updating multiple fields |
Date: | 1998-06-26 18:44:28 |
Message-ID: | v02140b73b1b94e8e4af0@[207.152.64.133] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
At 10:20 AM 6/26/98, Joao Paulo Felix wrote:
>Hello there,
>
>I have the following fields description, info and title.
>Is there a PostgreSQL query to update more than one field at the same
>time?
>
>Right now I have the following (I am using it with PHP, so please
>desregard its code):
>
>pg_Exec($conn, "UPDATE options SET description = '$description'
> WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET info = '$info'
> WHERE product = '$product' AND title = '$old_title';");
>
>pg_Exec($conn, "UPDATE options SET title = '$title'
> WHERE product = '$product' AND title = '$old_title';");
Hey! One I can answer!
typos may exist:
pg_Exec($conn, "UPDATE options SET description = '$description', info =
'$info', title = '$title' WHERE product = '$product' AND title =
'$old_title'");
Basically, you can have as many ", field = $value" entries as you like.
I also purposefully stripped off the ';' inside the string because
PostgreSQL doesn't need it, and some other database backend barfs when you
use it, so if you ever want to port, you don't want the ';' as part of the
SQL. Capiche?
--
--
-- "TANSTAAFL" Rich lynch(at)lscorp(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Brian | 1998-06-26 20:57:14 | Are there any books |
Previous Message | Joao Paulo Felix | 1998-06-26 17:20:38 | Updating multiple fields |