I'm trying to write a trigger that will take any any daily_rate that is over 15 and put it into a new table known as valuable_item. I have already created the new table and so all I need is to carry over the required data. Below is the code I have tried within the trigger edit section:
INSERT INTO valuable_items (catalogue_id,
description,
designer,
type,
daily_rate)
VALUES
(new.catalogue_id,
new.description,
new.designer,
new.type,
new.daily_rate, WHERE daily_rate >= 15
Guess you are looking for this, for within the trigger:
IF new.daily_rate >= 15 THEN
INSERT INTO valuable_items (catalogue_id,
description,
designer,
type,
daily_rate)
VALUES
(new.catalogue_id,
new.description,
new.designer,
new.type,
new.daily_rate);
END IF;
Try this:
IF new.daily_rate >= 15 THEN
INSERT INTO valuable_items (
catalogue_id,
description,
designer,
type,
daily_rate)
VALUES
(new.catalogue_id,
new.description,
new.designer,
new.type,
new.daily_rate);
END IF;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.