我有 2 个表 table1 和 table2。我必须将名为“C”的列从 table2 复制到 table1 中的“C”列,而不会丢失任何其他列数据。两种字段数据类型相同。任何人都可以给我一个正确的查询如何去做。
最佳答案
假设 Table1 已经包含 C 列,您可以通过 id 加入:
UPDATE table1 t1 JOIN table2 t2 ON t1.id = t2.id
SET t1.col1 = t2.col2, t1.col2 = t2.col2
来源:http://blog.ookamikun.com/2008/03/mysql-update-with-join.html
关于MySQl 查询 : copy a column named 'C' from table2 to column 'C' in table1 without losing any other column data,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7171062/