您的位置:

关于mysql同时更新多个数据库表的信息

本文目录一览:

Mysql 触发器 同时更新多张表

虽然不明白你的问些什么,但里面有几个语法错误我帮你改一下

CREATE

TRIGGER

t_AfterUpdate_on_mst_officecurrency2

AFTER

UPDATE

ON

`mst_officecurrency`

FOR

EACH

ROW

begin

update

`mst_generalsetup`

set

`CurrencyName`=NEW.OfficeCurrencyName

where

`CurrencyName`=OLD.OfficeCurrencyName;

update

`mst_office`

set

`Currency`=NEW.OfficeCurrencyName

where

`Currency`=OLD.OfficeCurrencyName;

end;

怎样让mysql 同时更新两个数据库中的表

UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing'

WHERE LastName = 'Wilson'

mysql批量更新多表数据

mysql批量更新多表数据

update 库2.tb,库1.tb set 库2.tb.body=库1.tb.body where 库2.tb.id= 库1.tb.id

求MYSQL如何`批量`更新`多表`多字段`?

思路:找到table2的所有字段,然后在table1中更新这些字段。

1:如果你要求在table1中插入table2的数据

SET @pstSql =CONCAT('INSERT INTO table1 (',

(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name='table2' AND table_schema='你的表所在的数据库名称'),

') SELECT ',(SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name='table2' AND table_schema='你的表所在的数据库名称'),' From table2');

PREPARE stmt FROM @pstSql;

EXECUTE stmt;

2:如果你要求将table2的数据按照ID更新到table1中

SET @pstSql =CONCAT('update table1 a,table2 b set ',

(SELECT GROUP_CONCAT('a.',column_name,'=b.',column_name)

FROM information_schema.columns WHERE table_name='table2' AND column_name !='id' AND table_schema='你的表所在的数据库名称'),

' where a.id=b.id');

PREPARE stmt FROM @pstSql;

EXECUTE stmt;