Insert and delete data in table using before insert trigger
问题 I have created a trigger which inserts the last record of conversation table in conversation_h table, and delete that record from conversation using before insert event. Any other logic or code is also welcome but i want achieve the above using trigger only. DELIMITER $$ CREATE TRIGGER `transfer_data` BEFORE INSERT ON `conversation` FOR EACH ROW BEGIN if (select count(*) from `conversation`) > 2 then set @mid = (select id from conversation order by id asc limit 0,1); insert into conversation