Sql updating multiple rows from another table

07-Feb-2017 02:21

I have about 60,000 rows that I'm needing to update the information from column_a to column_b.For example, 60,000 customers need their arrival_time to match their departure_time. In 40 years, there's been some amazing functionality in the database. I want to write SQL ( not PL/SQL ) to update transaction table from mapping table at one stroke. regards & thanks pjp update ( select old.old_account_number, new.new_account_number from old_table old, mapping_table new where old.old_account_number = new.new_account_number ) set old_account_number = new_account_number; disabling foreign keys during the operation and enabling them afterward. update ( select old.old_account_number, new.new_account_number from old_table old, mapping_table new where old.old_account_number = new.old_account_number ) set old_account_number = new_account_number; (ie in the subquery, match the old account numbers not try matching the old in the old table to the new in the mapping table) Of course if the original posting had the CREATEs/INSERTS etc, it would have a quick and east test. For nearly half of that time, Ask Tom has been there. I have to update a transaction table where mapping is existing with old account no and new account number. Note that the auto_patient_id's are not sequentially numbered, so I can't use a "between" there. One, werte, is where I want the values to be stored to.THKON01is the table I want to read the values from.The SQL Server (Transact-SQL) UPDATE statement is used to update existing records in a table in a SQL Server database.There are 3 syntaxes for the UPDATE statement depending on whether you are performing a traditional update or updating one table with data from another table.

Let's say I have 3 users I want to do this for, then the structure for THKON01looks like this: I want them to be inserted so that the first value of THKON01() gets copied to the first value in werte (field of folder_id 1525), the second () gets to the second (folder_id 1526), and so forth.Secondly you have shown me to update table with "KEY PRESERVED" method. IT NEEDS THIS LOGICALLY regardless of the method used, so just add it (for if a row in OLD joins to more than one row in NEW -- you are hosed, you cannot update this data, therefore NEW has a unique/primary key, add it to facilitate the update) I had a similiar query and i tried applying to my tables. If it is not possible can you show me how to write "GOOD" sql ? i.e, one column of a table should get updated from another column of another table. I understand that I can do this with one row and it work with a nested select statement in an update statement.When trying to update multiple rows though I believe I'm getting stuck on having to have 60,000 unique key identifiers.

Let's say I have 3 users I want to do this for, then the structure for THKON01looks like this: I want them to be inserted so that the first value of THKON01() gets copied to the first value in werte (field of folder_id 1525), the second () gets to the second (folder_id 1526), and so forth.Secondly you have shown me to update table with "KEY PRESERVED" method. IT NEEDS THIS LOGICALLY regardless of the method used, so just add it (for if a row in OLD joins to more than one row in NEW -- you are hosed, you cannot update this data, therefore NEW has a unique/primary key, add it to facilitate the update) I had a similiar query and i tried applying to my tables. If it is not possible can you show me how to write "GOOD" sql ? i.e, one column of a table should get updated from another column of another table. I understand that I can do this with one row and it work with a nested select statement in an update statement.When trying to update multiple rows though I believe I'm getting stuck on having to have 60,000 unique key identifiers.regards & thanks pjp June 29, 2005 - am UTC select as many old columns as you want and as many new columns as you want??? But when i did the same with the syntax given i got this error ora-01779 cannot modify a column which maps to a non key preserved value. I tried doing the same through this update ( select old.