Re: Assistance with trigger
Machiel Richards <[email protected]> Fri, 26 Apr 2019 09:17:13 +0000
| Newsgroups | gmane.comp.db.mysql.general |
|---|---|
| Message-ID | <AM0P192MB0275C297D0A75B11198E6691CF3E0@AM0P192MB0275.EURP192.PROD.OUTLOOK.COM> |
--_000_AM0P192MB0275C297D0A75B11198E6691CF3E0AM0P192MB0275EURP_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please ignore my request as I have managed to figure this out. Thank you. had to rewrite the insert to use Old.Column1... etc... and that works quite= well. ________________________________ From: Machiel Richards <[email protected]> Sent: Friday, 26 April 2019 10:48 AM To: [email protected] Subject: 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 o= f 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 TABLE= A... However upon delete it inserts the whole table instead of only the sin= gle row being deleted. Here is my insert and select statement : INSERT INTO tableB (Column1,backup_date,updated_by_user,Column4) SELECT Col= umn1,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 --_000_AM0P192MB0275C297D0A75B11198E6691CF3E0AM0P192MB0275EURP_--