Re: UPDATE with JOIN

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "PostgreSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: UPDATE with JOIN
Date: 2005-05-24 20:31:15
Message-ID: 20050524202906.M48823@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 24 May 2005 14:26:21 -0400, Tom Lane wrote
> "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
>

Thanks Tom

I couldn't figure out how to do the JOIN part of that statement. Using your
instruction all I had left to do was drop the qualification off the SET column
and it worked. :-) Thanks again.

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

Kind Regards,
Keith

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Ramon Orticio 2005-05-25 00:48:24 posgres files
Previous Message Yamamoto makoto 2005-05-24 19:38:41 大人の情報メールマガジン局 Vo.0015