Re: update on join ?

From: chester c young <chestercyoung(at)yahoo(dot)com>
To: Andreas <maps(dot)on(at)gmx(dot)net>
Cc: sql pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: update on join ?
Date: 2007-11-22 03:41:54
Message-ID: 169536.38344.qm@web54304.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


> I tried
>
> UPDATE things JOIN inventory ON things.thing_id = inventory.thing_fk
> SET number = 0
> WHERE color = 'red'
>

use the cool "from" clause in the update

update things t
set number = 0
from inventory i
where t.thing_id = i.thing_fk
and i.color = 'red';

____________________________________________________________________________________
Get easy, one-click access to your favorites.
Make Yahoo! your homepage.
http://www.yahoo.com/r/hs

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma Jr 2007-11-22 07:44:47 Bad Schema Design or Useful Trick?
Previous Message Richard Broersma Jr 2007-11-22 03:38:01 Re: update on join ?