我是MySQL存储过程的新手。不知道为什么我得到以下错误。请帮忙调试一下。
1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在'INTO this_user_id,this_user_fullname FROM user_master WHERE user_username = @th'第3行附近使用正确的语法
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 enum('ACTIVE','SUSPENDED','PENDING')是NULL
user_last_login_time timestamp是NULL
user_last_logout_time timestamp是NULL
IndexesDocumentation
PRIMARY BTREE是否user_id 4 A否
user_username_UNIQUE BTREE是否user_username 4是是
答案 0 :(得分:0)
这样做怎么样?
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;