Re: 3 tables join update

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: rihad <rihad(at)mail(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: Re: 3 tables join update
Date: 2007-09-29 18:31:29
Message-ID: 355878.78114.qm@web31802.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- rihad <rihad(at)mail(dot)ru> wrote:
> UPDATE Foo foo
> SET foo.baz_id=baz.id
> FROM Baz baz LEFT JOIN Bar bar ON (foo.bar_id=bar.id)
> WHERE bar.id IS NULL;

This query cannot work. Basiclly, you are trying to set the foo.baz_id = baz.id for records in
foo that do not yet exist. Doing this is impossible.

For this to work, you should be using an INSERT query to _ADD_ records to foo that do not yet
exist.

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message CN 2007-09-30 03:55:00 Re: Please change default characterset for database cluster
Previous Message rihad 2007-09-29 18:03:49 3 tables join update