pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: update from select
Date: Wed, 29 Oct 2003 06:58:42 -0800 (PST)
Message-ID: <20031029065413.C97497@megazone.bigpanda.com> (raw)
In-Reply-To: <200310290911.54453.gary.stainburn@ringways.co.uk>
References: <200310290911.54453.gary.stainburn@ringways.co.uk>

On Wed, 29 Oct 2003, Gary Stainburn wrote:

> Hi folks,
>
> don't know if it's cos of the 17 hours I've just worked (sympathy vote please)
> but I can't get this one worked out
>
> I've got table names with nid as name id field and nallowfollow flag.
> I've got a vehicles table with vowner pointing at nid and a vallowfollow
> field.
>
> How can I update nallowfollow from the appropriate vallowfollow flag?

If vehicles.vowner is unique, something like this maybe (using extensions
to sql)?
update names set nallowfollow=vehicles.vallowfollow
 from vehicles where vehicles.vowner=names.nid;

I think it'd be the follwoing in straight sql:
update names set nallowfollow=
 (select vallowfollow from vehicles where vehicles.vowner=names.nid);


If it's not unique, what do you do if there are two vehicles with the same
vowner and different values for vallowfollow?



view thread (10+ messages)  latest in thread

Message-ID: <20031029065413.C97497@megazone.bigpanda.com>
Permalink:  ../20031029065413.C97497@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20031029065413.C97497@megazone.bigpanda.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: sszabo@megazone.bigpanda.com, gary.stainburn@ringways.co.uk
  Subject: Re: update from select
  In-Reply-To: <20031029065413.C97497@megazone.bigpanda.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