Re: Converting SQL to pg

From: Tommy Gildseth <tommy(dot)gildseth(at)usit(dot)uio(dot)no>
To: martin(at)cornhobble(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Converting SQL to pg
Date: 2009-07-24 09:09:48
Message-ID: 4A697A5C.7020003@usit.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

martin(at)cornhobble(dot)com wrote:
> I must be tired. Any suggestions on converting the following to postgresql?
>
> UPDATE IGNORE yose5_user_newflags AS flags, yose5_messages AS
> msg SET flags.forum_id = msg.forum_id WHERE flags.message_id =
> msg.message_id AND flags.message_id IN (15580, 15581, 15706,
> 15712, 15713, 15719, 15888)
>
>

Untested, but I imagine it would be something like this.

UPDATE yose5_user_newflags AS flags
SET forum_id = msg.forum_id
FROM yose5_messages AS msg
WHERE flags.message_id = msg.message_id AND flags.message_id IN (15580,
15581, 15706, 15712, 15713, 15719, 15888)

PostgreSQL doesn't have anything similar to IGNORE (afaik), but
depending on what you want to do, you may be able to work around that
with deferred constraints etc.

--
Tommy Gildseth
DBA, Gruppe for databasedrift
Universitetet i Oslo, USIT
m: +47 45 86 38 50
t: +47 22 85 29 39

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Seaborn 2009-07-24 09:14:59 Re: Search Path vs Synonyms
Previous Message martin 2009-07-24 08:35:10 Re: Converting SQL to pg