php - Updating a column of the db after inserting

807

I have a tablelotto_epins with the following columns

lpin_id, lpin_serial, lpin_ec_id, lpin_epin, lpin_status

After inserting using PHP, I wish to update the columnlpin_serial by adding 0 in front of thelpin_id for a serial no.

I tried the following mysql trigger but it does not work.

CREATE TRIGGER `capital` BEFORE INSERT ON `lotto_epins`
FOR EACH ROW BEGIN
SET lpin_serial = LPAD(lpin_id,15,0) 
END;

How can I correctly update the column after inserting?

379

Answer

Solution:

delimiter //
CREATE TRIGGER capital BEFORE INSERT ON lotto_epins 
FOR EACH ROW 
BEGIN 
   SET NEW.lpin_serial = LPAD(NEW.lpin_id,15,0);
END //
delimiter ;

People are also looking for solutions to the problem: php - count items in cart different on_sale

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.