[ILUG] Database question...
rbmlist at gmail.com
Mon Dec 17 12:17:50 GMT 2012
Hmmm the best I can come up with is a case statement (which I haven't tried
but might work).
Update tablename set minval = case id when 1 then 15 when 2 then 10 end
On Dec 17, 2012 12:02 PM, "Braun Brelin" <bbrelin at gmail.com> wrote:
> Hi all,
> I've been searching on google and asking questions in forums with no real
> result, so I figured I'd try here:
> I'm using a postgres 9.1 database on Ubuntu Linux 12.04
> I have a table that looks like this:
> id serial primary key not null
> item_name varchar (40)
> item_amount integer
> I then want to add a new colum via alter table which is also an integer,
> such as item_amount_minimum_value
> Assuming that I already have data in the table for the other three columns,
> how can I populate the new column with data?
> I've tried doing this: update my_table set item_amount_minimum_value =
> but this fails as postgres thinks that the values are a row record and not
> a list of integers.
> I supposed I could do something like this: insert into my_table
> (item_amount_minimum_value) values (10),(5),(2), however is it possible to
> do this with an update rather than an insert?
> Braun Brelin
> Irish Linux Users' Group mailing list
> About this list : http://mail.linux.ie/mailman/listinfo/ilug
> Who we are : http://www.linux.ie/
> Where we are : http://www.linux.ie/map/
More information about the ILUG