Used MySQL - 5.7 - x64
Main table 1
CREATE TABLE `trg_02_1_test` ( `id_tbl_02_1` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, `cur_datetime_tbl_02_1` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `pol_1_date_tbl_02_1` DATE NULL DEFAULT NULL, `pol_2_enum_tbl_02_1` ENUM('Y','N') NULL DEFAULT NULL, `pol_3_longtxt_tbl_02_1` LONGTEXT NULL, `pol_4_txt_tbl_02_1` TEXT NULL, `pol_5_int_tbl_02_1` INT(11) NULL DEFAULT NULL, PRIMARY KEY (`id_tbl_02_1`) ) LONGTEXT\r\n' COLLATE='utf8_general_ci' ENGINE=MyISAM ROW_FORMAT=DYNAMIC AUTO_INCREMENT=7 ; Log table
CREATE TABLE `trg` ( `datetime_log` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `tbl_02_name_log` TEXT NULL, `id_tbl_02_n_log` INT(11) NULL DEFAULT NULL, `tbl_02_pol_name_log` TEXT NULL, `tbl_02_pol_content_log` TEXT NULL ) LONGTEXT\r\n' COLLATE='utf8_general_ci' ENGINE=MyISAM ROW_FORMAT=DYNAMIC ; Trigger for logging
CREATE DEFINER=`root`@`%` TRIGGER `trg_02_1_test_before_update` BEFORE UPDATE ON `trg_02_1_test` FOR EACH ROW BEGIN INSERT INTO trglog Set id_tbl_02_n_log = NEW.id_tbl_02_1, tbl_02_pol_content_log = NEW.pol_4_txt_tbl_02_1; END It is supposed to put data from several tables in the log.
Question.
How to make the log:
in the tbl_02_name_log field - the name of the table in which the update takes place was substituted;
- in the tbl_02_pol_name_log field - the name of the field in which the update occurs is substituted;
?