Задавайте вопросы, мы ответим
Вы не зашли.
Помогите разобраться, почему не работает триггер (Выбивает #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3 )
CREATE TRIGGER `ORDERING` BEFORE INSERT ON `orders` FOR EACH ROW BEGIN
IF (SELECT COUNT(id_orders) FROM orders WHERE id_cl=NEW.id_cl)=3 THEN
UPDATE clients SET discount='5%' WHERE id_clients=NEW.id_cl;
END IF;
IF(SELECT discount FROM clients WHERE id_clients=NEW.id_cl)='5%' THEN
SET NEW.oplata=TRUNCATE((SELECT price_product FROM products WHERE id_products=NEW.id_prod)*0.95,2);
ELSE SET NEW.oplata=TRUNCATE((SELECT price_product FROM products WHERE id_products=NEW.id_prod),2);
END IF;
IF (SELECT COUNT(id_orders) FROM orders WHERE id_cl=NEW.id_cl)=8 THEN
UPDATE clients SET discount='10%' WHERE id_clients=NEW.id_cl;
END IF;
IF(SELECT discount FROM clients WHERE id_clients=NEW.id_cl)='10%' THEN
SET NEW.oplata=TRUNCATE((SELECT price_product FROM products WHERE id_products=NEW.id_prod)*0.90,2);
ELSE SET NEW.oplata=TRUNCATE((SELECT price_product FROM products WHERE id_products=NEW.id_prod),2);
END
Неактивен
вероятно delimiter не указали
http://sqlinfo.ru/articles/info/15.html
Неактивен