ohadinho ohadinho - 6 months ago 16
MySQL Question

Syntax error in MySQL Error #1064

I'm trying to execute the following query:

DELIMITER $$
USE user_access
CREATE PROCEDURE check_user_login(IN username VARCHAR(50),IN `password` VARCHAR(50))
BEGIN
SELECT 1
FROM user_access
WHERE UserName='$username' AND `Password`='$password'
END$$
DELIMITER ;


But getting this 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 'CREATE PROCEDURE check_user_login(IN username VARCHAR(50),IN `password` VARCHAR(' at line 2


What's wrong with the query?

Answer

You missed the ; in two places.

DELIMITER $$
USE user_access; -- you missed the semicolon
CREATE PROCEDURE check_user_login(IN username VARCHAR(50), IN `password` VARCHAR(50))
BEGIN
    SELECT 1
    FROM `user_access`
    WHERE UserName = username AND `Password` = `password`; -- you missed the semicolon
END$$
DELIMITER ;
Comments