Demand:
The boss gave an Excel data, is a template I provide, including ID, now equivalent to import this new column of data to a table in the database.
Method One: Use Navicat, copy a column in Excel, and then paste it into a column in the Navicat
Method two: Using SQL method: First build a temporary table, import the data, there are IDs and desc two columns, and then execute the following statement
UPDATE Gy_doctor A, gy_tmp b SET a.dr_desc = b. ' desc '
WHERE a.dr_id = b.id;
With table T1:
ID Name
1 null
2 NULL
3 null
Table T2:
ID Name
1 AA
2 BB
3 cc
Now you want to assign the name column of T2 to the name column of T1, with the ID as the corresponding row:
Update T1,t2
Set T1.name=t2.name
where t1.id=t2.id
Results after execution: Table T1:
ID Name
1 AA
2 BB
3 cc
MySQL uses one column of a table to update another column of this table:
With table T1:
ID Name
1 null
2 NULL
3 null
Now copy the value of the ID column of the T1 table to the T1 name columns:
Update T1
Set Name=id
Results after execution: Table T1:
ID Name
1 1
2 2
3 3
MySQL uses one column of a table to update a column of another table