我正在寻找类似的东西 -
insert into table1(a, b, c)
select col1 as d, col2 as e, col3 as f from table2
on duplicate key update b = e, c = f;
注意 - 这里table1.a是唯一的密钥。
我收到错误 - 未知列名' e'
是否有任何解决方案可供使用'在重复密钥'使用'插入选择'声明?
谢谢!
答案 0 :(得分:2)
使用别名造成的混乱
insert into table1(a, b, c)
select col1 as d, col2 as e, col3 as f from table2
on duplicate key update b = table2.col2, c = table2.col3;