Web lists-archives.com

Assistance with trigger




Hi All

   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.

Regards