Re: [GENERAL] 3 tables join update

2007-10-01 Thread Alban Hertroys
rihad wrote: > Richard Broersma Jr wrote: > UPDATE Foo foo > SET ... > FROM LEFT JOIN Bar bar USING(common_field) > WHERE blah='blah' AND bar.common_field IS NULL; > > ERROR: syntax error at or near "JOIN" > > > I know I'm misusing UPDATE ... FROM because I don't really want Bar's > values to g

Re: [GENERAL] 3 tables join update

2007-09-30 Thread rihad
Richard Broersma Jr wrote: --- rihad <[EMAIL PROTECTED]> 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

Re: [GENERAL] 3 tables join update

2007-09-30 Thread rihad
Richard Broersma Jr wrote: --- rihad <[EMAIL PROTECTED]> 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. I know. So how do I do it efficiently? Thanks. ---(end of broadc

Re: [GENERAL] 3 tables join update

2007-09-29 Thread Richard Broersma Jr
--- rihad <[EMAIL PROTECTED]> 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 i