CREATE TABLE wishlist(
year YEAR NOT NULL,
ssn CHAR(14),
delivered BIT,
PRIMARY KEY (year, ssn),
FOREIGN KEY (ssn) REFERENCES child (child_ssn)
) engine=innodb;
CREATE TABLE wishlistDelivered(
year YEAR NOT NULL,
ssn CHAR(14),
delivered BIT,
PRIMARY KEY (year, ssn),
FOREIGN KEY (ssn) REFERENCES child (child_ssn)
) engine=innodb;
DELIMITER //
CREATE TRIGGER triggerdelivered after insert on wishlist
FOR EACH ROW BEGIN
INSERT INTO wishlistDelivered
SELECT * FROM wishlist WHERE delivered = 1;
DELETE FROM wishlist WHERE delivered = 1;
END;
//
DELIMITER ;
I'm essentially trying to create a trigger where it moves all wishlist items that's been delivered to a cold storage. If a toy is delivered, the value is "1" in the delivered column in the wishlist table. However, I can still insert data where the value is "1" and it does not update the wishlistDelivered table nor remove the data from the wishlist table. What am I missing?