轉載自:http://www.educity.cn/wenda/396165.html
mysql從一個表字段賦值給另一個表字段 收集
方法一:
mysql從一個表字段賦值給另一個表字段,在線等待。
table1 中 有字段 id,uid,name
table2 中 有字段 id,name
table1中的uid和table2中的id是一一對應的。
我如何把table2中的name一一對應賦值給table1中name
我的環境是MYSQL4.0.18nt+PHP4
------解決方案--------------------
INSERT INTO table1 (uid, name)
SELECT id AS uid,
name
FROM table2;
------解決方案--------------------
update table1,table2 set table1.name = table2.name where table1.uid = table2.id;