Re: Assistance with trigger
Please ignore my request as I have managed to figure this out.
had to rewrite the insert to use Old.Column1... etc... and that works quite well.
From: Machiel Richards <machiel@xxxxxxxxxxxxxxxxxxxx>
Sent: Friday, 26 April 2019 10:48 AM
Subject: Assistance with trigger
I am hoping this email finds all well.
I would like to request some assistance with a MySQL trigger please.
We need to implement a trigger that will in short terms make a backup of a row before it gets deleted.
so we have tableA and TableB (backup table).
I added a before delete trigger to insert into TABLEB select from TABLEA... However upon delete it inserts the whole table instead of only the single row being deleted.
Here is my insert and select statement :
INSERT INTO tableB (Column1,backup_date,updated_by_user,Column4) SELECT Column1,NOW(),`username`,Column2 from tableA;
How can I rewrite this section to only select and insert the rows that are actually being deleted.
Your help would be greatly appreciated as I have not been able to find the answer on google as yet.