当我想根据 1 个参数连接 2 个表并只更新 1 列时,我使用以下语法
UPDATE your_table
INNER JOIN your_temp_table on your_temp_table.name= your_table.name
SET your_table.surname= your_temp_table.surname;
但是,如果我想根据 2 个参数(姓名和城市)连接表并更新 2 列(姓氏和日期)怎么办?你能帮我找到解决方案吗?
最佳答案
使用逗号设置多列:
UPDATE your_table
INNER JOIN your_temp_table on your_temp_table.name= your_table.name and
your_temp_table.city= your_table.city
SET your_table.surname= your_temp_table.surname,
your_table.`date`=your_temp_table.`date`;
关于mysql - sql基于2个参数连接表并更新2列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34960635/