If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Select from table, reinsert data but update one of the columns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-14-04, 19:03
elstretcho elstretcho is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Question Select from table, reinsert data but update one of the columns

I want to copy many rows from a table and re-insert them into the same table but changing one of the fields.

1) select * from curve_def_derived_sec
where curve_id = 362
and def_datetime > '09 Jan 04'

2) Now I want to insert the results from the above query back into table curve_def_derived_sec but change the results so that curve_id = 264

Note the curve_id is a primary key.

Aside from doing an insert for every line with the values, does anyone know of a mass update.

Last edited by elstretcho; 03-14-04 at 19:06.
Reply With Quote
  #2 (permalink)  
Old 03-15-04, 02:42
marp marp is offline
Registered User
 
Join Date: Jan 2004
Location: Romania - Bucharest
Posts: 50
If you want only7 to change the Curve_id:

Update curve_def_derived_sec
Set curve_id = 264
where curve_id = 362
and def_datetime > '09 Jan 04'

Or, if you want to insert new rows:

Insert << Field List, including curve_if>>

into curve_def_derived_sec

Select <<all fields but curve_id>>, 362

from (select * from curve_def_derived_sec
where curve_id = 362
and def_datetime > '09 Jan 04')

Does it answer your question?

-------------------------------------------------------------------

I want to copy many rows from a table and re-insert them into the same table but changing one of the fields.

1) select * from curve_def_derived_sec
where curve_id = 362
and def_datetime > '09 Jan 04'

2) Now I want to insert the results from the above query back into table curve_def_derived_sec but change the results so that curve_id = 264

Note the curve_id is a primary key.

Aside from doing an insert for every line with the values, does anyone know of a mass update
Reply With Quote
  #3 (permalink)  
Old 03-15-04, 14:43
elstretcho elstretcho is offline
Registered User
 
Join Date: Mar 2004
Posts: 2
Cheers, exactly what I needed.

Quote:
Originally posted by marp
If you want only7 to change the Curve_id:

Update curve_def_derived_sec
Set curve_id = 264
where curve_id = 362
and def_datetime > '09 Jan 04'

Or, if you want to insert new rows:

Insert << Field List, including curve_if>>

into curve_def_derived_sec

Select <<all fields but curve_id>>, 362

from (select * from curve_def_derived_sec
where curve_id = 362
and def_datetime > '09 Jan 04')

Does it answer your question?

-------------------------------------------------------------------

I want to copy many rows from a table and re-insert them into the same table but changing one of the fields.

1) select * from curve_def_derived_sec
where curve_id = 362
and def_datetime > '09 Jan 04'

2) Now I want to insert the results from the above query back into table curve_def_derived_sec but change the results so that curve_id = 264

Note the curve_id is a primary key.

Aside from doing an insert for every line with the values, does anyone know of a mass update
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On