1

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?

2 Answers 2

1

Looks to me like there's no separation between use user_access and create procedure, perhaps this will help you along:

USE user_access;
DELIMITER $$
CREATE PROCEDURE ...

also, your parameter syntax looks wrong to me, you don't want '$username' just username should do as it is the name of your parameter.

Sign up to request clarification or add additional context in comments.

2 Comments

now i'm getting: #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 'END' at line 6
here is the new query: USE storedb; DELIMITER $$ 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 ;
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.