Re: UPDATE with JOIN - Mailing list pgsql-novice

From Tom Lane
Subject Re: UPDATE with JOIN
Date
Msg-id 4584.1116959181@sss.pgh.pa.us
Whole thread Raw
In response to UPDATE with JOIN  ("Keith Worthington" <keithw@narrowpathinc.com>)
Responses Re: UPDATE with JOIN  ("Keith Worthington" <keithw@narrowpathinc.com>)
List pgsql-novice
"Keith Worthington" <keithw@narrowpathinc.com> writes:
> UPDATE tbl_line_item
>    SET tbl_line_item.reviewed = TRUE
>   FROM tbl_item
>     ON ( tbl_line_item.item_id = tbl_item.id )
>  WHERE item_type = 'DIR';

Of course that's not valid JOIN syntax (no JOIN keyword, and no place to
put it either).  You have to use the WHERE clause:

UPDATE tbl_line_item
   SET tbl_line_item.reviewed = TRUE
  FROM tbl_item
 WHERE tbl_line_item.item_id = tbl_item.id
       AND item_type = 'DIR';

            regards, tom lane

pgsql-novice by date:

Previous
From: "Keith Worthington"
Date:
Subject: UPDATE with JOIN
Next
From: "Walker, Jed S"
Date:
Subject: Re: Sparse Data