sql - Update table values from another table with the same user name -


i have 2 tables, same column named user_name, saying table_a, table_b.

i want to, copy table_b, column_b_1, column_b2, table_b1, column_a_1, column_a_2, respectively, user_name same, how in sql statement?

as long have suitable indexes in place should work alright:

update table_a set       column_a_1 = (select table_b.column_b_1                              table_b                             table_b.user_name = table_a.user_name )     , column_a_2 = (select table_b.column_b_2                             table_b                             table_b.user_name = table_a.user_name )     exists (         select *         table_b         table_b.user_name = table_a.user_name     ) 

update in sqlite3 not support clause, makes little more work in other rdbms.

if performance not satisfactory, option might build new rows table_a using select , join table_a temporary table. delete data table_a , repopulate temporary.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -