您好,我想在插入表后创建一个触发器,此触发器的目的是更新同一表上的一行,这是我编写的代码,我使用phpmyadmin
UPDATE commande SET NEW.CodeLivreurClient= SHA1(concat(NEW.IdCommande,"_",NEW.DateCommande,"_",NEW.HoraireCommande,"_",NEW.IdClient))
下表如下:
CREATE TABLE `commande` (
`IdCommande` int(11) NOT NULL,
`DateCommande` date NOT NULL,
`HoraireCommande` time NOT NULL,
`MethodePaiement` varchar(256) NOT NULL,
`StatusPaiement` tinyint(1) NOT NULL,
`StatusCommande` varchar(256) NOT NULL,
`CodeLivreurRestaurant` varchar(6) DEFAULT NULL,
`CodeLivreurClient` varchar(6) DEFAULT NULL,
`IdLivreur` int(11) NOT NULL,
`IdClient` int(11) NOT NULL
)
触发器是:
CREATE DEFINER=root@localhost TRIGGER Apres_Insert_Commande
AFTER INSERT ON commande
FOR EACH ROW
UPDATE commande
SET NEW.CodeLivreurClien t= SHA1(concat(NEW.IdCommande,"", NEW.DateCommande,"", NEW.HoraireCommande, "_", NEW.IdClient));