Updating a table fields from another table columns we can user following syntax
1 2 3 4 5 | Update table1 inner join table2 on a.id=b.id set a.field1=b.field1 b.field2=b.field3 |
There are two tables table1 and table2. Both table have common id value. To select appropriate field from table inner join in used and updating table1 fields from table2 fields set statement is used.
For example there are two tables with following fields
user(id,fname,lname,mobileno,address,);
personal(id,fname,lname,mobile_no);
Here c=consider user and person have common id then to update user from person we can use following query
1 2 3 4 5 6 7 | update user as u inner join person p on u.id=p.id set u.fname=p.fname, u.lname=p.lname, u.mobile_no=p.mobno; |
This will update user table with person tables fields.