Re: UPDATE with JOIN

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: KeithW(at)narrowpathinc(dot)com
Cc: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: UPDATE with JOIN
Date: 2005-05-24 18:26:21
Message-ID: 4584.1116959181@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Keith Worthington" <keithw(at)narrowpathinc(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Walker, Jed S 2005-05-24 18:43:00 Re: Sparse Data
Previous Message Keith Worthington 2005-05-24 18:02:40 UPDATE with JOIN