From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
---|---|
To: | Matthew Price <pricem(at)juno(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Updating a table from another table |
Date: | 2002-06-04 21:38:19 |
Message-ID: | 3CFD334B.5242BB1B@nsd.ca |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Try:
UPDATE customers
SET canceldate = cancels.canceldate
FROM cancels
WHERE customers.custnum = cancels.custnum;
You should also have an index on cancels(custnum).
JLL
Matthew Price wrote:
>
> Howdy All,
>
> I need to update many records in one table with data from another table that ultimately gets \copy-ed from an outside source.
>
> customers:
> custnum varchar(6),
> name text,
> canceldate date
> ...
>
> cancels:
> custnum varchar(6),
> canceldate date
>
> What is the right way to update the canceldate in the customers table from canceldate in the cancels table? Is there a way to use update to iterate rather than making a mass change?
>
> Thanks in advance,
> Matthew
>
> ________________________________________________________________
> GET INTERNET ACCESS FROM JUNO!
> Juno offers FREE or PREMIUM Internet access for less!
> Join Juno today! For your FREE software, visit:
> http://dl.www.juno.com/get/web/.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
From | Date | Subject | |
---|---|---|---|
Next Message | Rui Pacheco | 2002-06-04 22:02:01 | Some problems with (my?) PlSQL |
Previous Message | Matthew Price | 2002-06-04 20:37:30 | Updating a table from another table |