Answer the question
In order to leave comments, you need to log in
How to create branches in MySQL: BEGIN, IF THEN?
MySQL gives an error in condition statements, but I do everything according to the reference book.
BEGIN;
SET @lines := 0;
SELECT count(*) FROM `prod_attr ` INTO @lines ;
IF @lines > 4000 THEN -- Тут ошибка
SELECT "MAX";
TRUNCATE TABLE `prod_attr ` ;
END IF;
END;
Answer the question
In order to leave comments, you need to log in
only inside the begin ... end block
BEGIN ... END syntax is used for writing compound statements, which can appear within stored programs (stored procedures and functions, triggers, and events
in this particular case, BEGIN is interpreted as an alias START TRANSACTION; , and IF - as a function
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question