Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Question Unanswered: 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 20:06.

  2. #2
    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

  3. #3
    Join Date
    Mar 2004
    Posts
    2
    Cheers, exactly what I needed.

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •