when I try to create a function to retrieve userName from user table using their email it gives me this useless error:
#1064 - 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 name VARCHAR; BEGIN select
userNameAS name fromuserWHERE `ema' at line 2
, the same code with a different syntax works in mssql so I wonder what is the difference? in better words what am I doing wrong here?
DELIMITER ;;
CREATE FUNCTION getUserName(email varchar(50)) RETURNS VARCHAR
BEGIN
DECLARE name VARCHAR;
SELECT `userName` AS name FROM `user` WHERE `email` = email;
RETURN name;
END ;;