当前位置:Gxlcms > 数据库问题 > Mysql 触发器 A表记录到B表

Mysql 触发器 A表记录到B表

时间:2021-07-01 10:21:17 帮助过:16人阅读

1:查询出需要的列名 备用

#列名
select COLUMN_NAME from information_schema.columns
where TABLE_SCHEMA=‘yunpiaobox_db‘ and table_name=‘t_box_status‘

 

TABLE_SCHEMA: 数据库名称    table_name:表名


#列名字符串 按,分隔
select
GROUP_CONCAT(COLUMN_NAME separator ‘,‘) ‘逗号分隔‘,
GROUP_CONCAT(CONCAT(‘NEW.‘, COLUMN_NAME) separator ‘,‘) ‘NEW.字段 逗号分隔‘,
GROUP_CONCAT(CONCAT(COLUMN_NAME, ‘=NEW.‘, COLUMN_NAME) separator ‘,‘) ‘字段=NEW.字段 逗号分隔‘
from information_schema.columns
where TABLE_SCHEMA=‘yunpiaobox_db‘ and table_name=‘t_box_status‘

 

2:工具Navicat Premium 右击A表  ---> 设计表 --->  选择触发器

技术分享

 

Mysql 触发器 A表记录到B表

标签:inf   stat   status   字符   png   image   from   where   navicat   

人气教程排行