Advertisement

07.22.2008 at 11:30PM PDT, ID: 23587518
[x]
Attachment Details

select, modify, insert

Asked by sunnycoder in PostgreSQL Database, Databases Miscellaneous, Data Manipulation

Tags: Postgres SQL

I need to select some rows from a table based on a certain field, something like

select * from table where ts=100

On these rows, I need to edit the value in ts to current value (100 in the above example) and increase it by a constant amount (say 50 so that new value is ts=150 for all these rows)

While retaining the old rows in the table, these new rows also need to be inserted into the table.

e.g. If the table was

ts        A       B     C
100     x       y      z
90       a       d      f
30       s        y     z
100     c        v     b

Then new table would be
ts        A       B     C
100     x       y      z
90       a       d      f
30       s        y     z
100     c        v     b
150     x       y      z
150     c        v     b

Using PostgreSQLStart Free Trial
[+][-]07.22.2008 at 11:34PM PDT, ID: 22066516

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PostgreSQL Database, Databases Miscellaneous, Data Manipulation
Tags: Postgres SQL
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.22.2008 at 11:42PM PDT, ID: 22066545

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2008 at 12:26AM PDT, ID: 22066745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628