MYSQL - 从另一个 table 更新多行

MYSQL - UPDATE multiple rows from another table

我有2张桌子。一个是昨天的(300k 行),另一个是今天的,行数相同,但某些列的数据发生了变化。

这两个表大约有 120 列。

我怎样才能只更新更改。
我试过使用 delete :

   delete from tableA
   where id in (select id from tableB)

但是太慢了。
也试过

   update tableA inner join tableB
   on tableA.id=TableB.id

但没有用。

从表A中删除 其中 id in (select id from tableB)

代替上面的查询试试这个:-

Delete tableA from tableA left Join tableB ON  tableA.id = tableB.id where tableB.id IS NOT NULL;

您必须在更新查询中设置值才能获得更改。

示例:

update tableA inner join tableB on tableA.id=TableB.id
set tableA.col1=TableB.col1,
    tableA.col2=TableB.col2,
    tableA.col3=TableB.col3;

您还可以在 where 子句中添加更多条件,以对过滤记录进行查询 运行。