[英]Having SQL Syntax error in MySQL stored procedure
我是MySQL存储过程的新手。 不知道为什么会出现以下错误。 请帮助调试。
1064-您的SQL语法有误; 在第3行的“ INTO this_user_id,this_user_fullname FROM user_master WHERE user_username = @th”附近,查看与您的MySQL服务器版本相对应的手册以使用正确的语法。
DELIMITER $$
CREATE PROCEDURE loginUser(IN this_user_name VARCHAR(100), IN this_user_password VARCHAR(100), OUT this_user_id BIGINT(11), OUT this_user_fullname VARCHAR(100))
BEGIN
IF NOT EXISTS (SELECT user_id, user_full_name INTO this_user_id, this_user_fullname FROM user_master WHERE user_username = this_user_name AND user_password = this_user_password) THEN
SET this_user_id = NULL;
SET this_user_fullname = NULL;
END IF;
END$$
表名称:user_master
user_id bigint(11)否
user_full_name varchar(100)是NULL
user_username varchar(60)是NULL
user_password varchar(45)是NULL
user_security_question varchar(225)是NULL
user_security_answer varchar(255)是NULL
user_salt varchar(30)是NULL
user_status枚举('ACTIVE','SUSPENDED','PENDING')是NULL
user_last_login_time时间戳是NULL
user_last_logout_time时间戳是NULL
索引文件
主BTREE是否user_id 4 A否
user_username_UNIQUE BTREE是否user_username 4 A是
怎么做呢?
BEGIN
-- Initialize the variables
SET this_user_id = NULL;
SET this_user_fullname = NULL;
-- Set them
SELECT user_id, user_full_name
INTO this_user_id, this_user_fullname
FROM user_master
WHERE user_username = this_user_name AND user_password = this_user_password;
. . .
END;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.