I try to write a trigger that would work when deleting a record from a table and transferring the deleted value to the backup table.

CREATE DEFINER=`root`@`localhost` TRIGGER `lands_BEFORE_DELETE` BEFORE DELETE ON `lands` FOR EACH ROW BEGIN INSERT history_table_epl(history_text_epl) SELECT nameL FROM lands; END 

Actually, the trigger is triggered, but it generally transfers all the entries from this column of the lands table, and I only need that particular value from the nameL column, which I delete. I understand that I need to add some condition in WHERE, but I don’t know which one, so I’m asking for help) I’m doing all this in MySQL Workbench.

Table structure: enter image description here

    1 answer 1

    Maybe someone will come in handy:

      CREATE DEFINER=`root`@`localhost` TRIGGER `lands_BEFORE_DELETE` BEFORE DELETE ON `lands` FOR EACH ROW BEGIN INSERT history_table_epl(history_text_epl) values (OLD.nameL); END