I have a .bat
file which executes the SQL file as follows.
The aim is that if records are found in a table, nothing will be done, whereas if the table is empty, some records will be inserted.
BEGIN
DECLARE rowCount INT;
SELECT count(*) FROM `martin1` INTO rowCount;
IF rowCount <= 5 THEN
END IF;
END;
But when I execute it, there is an error. I tried to delete the DECLARE
, but even for (IF SELECT COUNT(*)...>0)
there is still an error.
The error is,
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE rowCount INT' at line 2
How can I resolve this?