Search Postgresql Archives

Re: Need help on updating an entire column with a list of values, I have.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26 March 2010 13:47, Rajan, Pavithra <RAJANP@xxxxxxxxx> wrote:
> Hello - I have this table with 90 rows, which contains 2 columns ,column A
> (type 'numeric') and column B(type text) . Column 'A' is filled with a
> constant number and column 'B' has an unique entry for each row.
>
> E.g.              A                 B
>          (numeric)        (text)
>
>             15968.0           002
>         15968.0           003
>         15968.0           004
>         15968.0           011
>         15968.0           012
>         15968.0           057
>         15968.0           006
>         15968.0           009
>         15968.0           010
>              ..
>              ..
> I would here want to update the entire column A with a list of values that I
> have.(
> 06959.0,15308.0,15968.0,18916.2,19961.0,26528.0,29553.0,29872.0,30631.0
> …).How do I accomplish this? Thank you.
>

It looks like you'd need to do something like the following:

UPDATE my_table SET a = 06959.0 WHERE b = '002';
UPDATE my_table SET a = 15308.0 WHERE b = '003';
UPDATE my_table SET a = 15968.0 WHERE b = '004';

etc

Not sure about your column layout though.  The primary key (in this
case your column B) would usually appear as the first column, and does
it always contain numbers?  If so, wouldn't an int be better?

Thom

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux