im having trouble finding the correct syntax i always having error #1064.
error: #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 ';
this is the code;
DELIMITER $$
DROP FUNCTION IF EXISTS formula
$$
CREATE FUNCTION formula
(iq INT, sq INT, ig INT) RETURNS INT
BEGIN
DECLARE result INT;
SET result = (iq-((sq/30)) * ig;
IF result >= 0 THEN
RETURN result;
ELSEIF result < 0 THEN
RETURN 0;
END IF;
END; $$
DELIMITER;
i've searching for the answer in the web nothing i can find. what is the wrong with my syntax?
you have a very small mistake in the code.
DELIMITER $$
DROP FUNCTION IF EXISTS formula$$
CREATE FUNCTION formula(iq INT, sq INT, ig INT) RETURNS INT
BEGIN
DECLARE result INT;
SET result = (iq-((sq/30))) * ig; ---> You missed an closing bracket (")") here
IF result >= 0 THEN RETURN result; ELSEIF result < 0 THEN RETURN 0; END IF; END; $$
DELIMITER;
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.