pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Moiz Kothari <moizpostgres@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Update query by joining multiple tables.
Date: Wed, 17 Jan 2007 16:50:18 +0530
Message-ID: <82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com> (raw)

Guys,

on page this

http://www.postgresql.org/docs/8.1/interactive/sql-update.html, it is not
specified if a join can be done between multiple tables to update a table, i
tried and it worked just fine for me. Something like this :

Infact update can work between multiple tables to... do something like :

UPDATE employees SET sales_count = a.sales_count FROM accounts as a
  WHERE a.name = 'Acme Corporation'
  AND employees.id = a.sales_person;

considering sales_count as a column in accounts table.

Regards,
Moiz

view thread (3+ messages)  latest in thread

Message-ID: <82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com>
Permalink:  ../82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com/
Also on:    postgresql.org/message-id/82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: moizpostgres@gmail.com
  Subject: Re: Update query by joining multiple tables.
  In-Reply-To: <82e1a9bd0701170320j14d4ebdagd66d8c9f095b0192@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox