This is my Table_A
This is my Table_B
What I have to do is Update costomer_package_id field of Table_A with corresponding customer_package_id in Table_B. See below Figure.
There are several hundreds of statements in both tables. Before update Table_A. So I executed select query before update.
Select Query.
SELECT `a`.`cus_id`,`b`.`customer_package_id`, `a`.`priority` FROM `Table_A` `a` INNER JOIN `Table_B` `b` ON `a`.`cus_id`=`b`.`cus_id`
Then I have executed update query.
UPDATE `TABLE_A` `a` JOIN `TABLE_B` `b` ON `a.cus_id = b.cus_id` SET `a.customer_package_id = b.customer_package_id`
Following Update Query also worked for me.
UPDATE `table_A` `a` JOIN `table_B` `b` ON `a.cus_id` = `b.cus_id` SET `a.customer_package_id` = `b.customer_package_id`
It got several seconds to execute the update query. My Job Done !
0 comments:
Post a Comment
Ask anything about this Tutorial.