Skip site navigation (1) Skip section navigation (2)

Re: Need some help with crafting a query to do major update

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Sean Shanny <shannyconsulting(at)earthlink(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Need some help with crafting a query to do major update
Date: 2004-02-19 03:11:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Wed, 18 Feb 2004, Sean Shanny wrote:

> To all,
> This is part of a data warehouse.  Made the mistake of using a natural
> key in one of the fact tables.  :-(  The f_test_pageviews is a simple
> testing table while I work this out.  The real table has an identical
> schema.
> I have built a mapping table, d_user, to allow the replacement of the
> text based (32 characters wide) subscriber_key in f_test_pageviews with
> an int4 mapping key.  I need to replace all of the
> f_test_pageviews.subscriber_key values with the value putting
> it in f_test_pageviews.sub_key column.
> I have tried this sql:
> update f_test_pageviews set sub_key = from f_test_pageviews t1,
> d_user t2 where t1.subscriber_key = t2.user_id;

I don't think the above does what you want because I don't think you meant
to be joining f_test_pageviews in twice (once as the table to be updated
and once as t1) or at least not without limiting which rows you want to

I think you probably just want:
update f_test_pageviews set from d_user t2 where

In response to

pgsql-sql by date

Next:From: IainDate: 2004-02-19 03:44:22
Subject: Re: Indexes and statistics
Previous:From: Sean ShannyDate: 2004-02-19 00:51:08
Subject: Need some help with crafting a query to do major update

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group