sql - Update query with INNER Join -


i have 2 tables manual_transactions , manual_list_temp. wanted achieve update manual_transactions information manual_list_temp. here records present in manual_list_temp table should updated manual_transactions.

i have done below problem following statement updates every records manual_transactions table.

update manual_transactions  set ( "age", "assigned_to", "attachments", "comments", "completed_date_time" , "content_type", "created", "created_by","cycle_time (crt complete)" , "cycle_time (first reply)", "distribution_channel")=         (select manual_list_temp."age", manual_list_temp."assigned_to",          manual_list_temp."attachments", manual_list_temp."comments",          manual_list_temp."completed_date_time", manual_list_temp."content_type",         manual_list_temp."created", manual_list_temp."created_by",          manual_list_temp."cycle_time (crt complete)",          manual_list_temp."cycle_time (first reply)",          manual_list_temp."distribution_channel"          manual_list_temp          manual_list_temp.id = manual_transactions.id) 

you should add clause update statement:

update manual_transactions  set ( "age", "assigned_to", "attachments", "comments", "completed_date_time" , "content_type", "created", "created_by","cycle_time (crt complete)" , "cycle_time (first reply)", "distribution_channel")=         (select manual_list_temp."age", manual_list_temp."assigned_to",          manual_list_temp."attachments", manual_list_temp."comments",          manual_list_temp."completed_date_time", manual_list_temp."content_type",         manual_list_temp."created", manual_list_temp."created_by",          manual_list_temp."cycle_time (crt complete)",          manual_list_temp."cycle_time (first reply)",          manual_list_temp."distribution_channel"          manual_list_temp          manual_list_temp.id = manual_transactions.id) manual_transactions.id in (select manual_list_temp.id manual_list_temp); 

for best results, convert update merge statement:

merge manual_transactions tgt using (         select manual_list_temp.id,         manual_list_temp."age", manual_list_temp."assigned_to",          manual_list_temp."attachments", manual_list_temp."comments",          manual_list_temp."completed_date_time", manual_list_temp."content_type",         manual_list_temp."created", manual_list_temp."created_by",          manual_list_temp."cycle_time (crt complete)",          manual_list_temp."cycle_time (first reply)",          manual_list_temp."distribution_channel"          manual_list_temp ) src on (tgt.id = src.id) when matched update set tgt."age" = src."age"   , tgt."assigned_to" = src."assigned_to"   [...] 

the merge statement update rows in manual_transactions (the target table) have matching rows in manual_list_temp (the source table).


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -