如果由于错误的密码或状态(由于电子邮件地址正确)导致登录失败,我的以下过程需要更新登录尝试。仅当带有盐的表中仅存在电子邮件地址时,才调用此过程。
SELECT
login.LOGIN_USER_ID,
login.LOGIN_EMAIL,
login.LOGIN_ACCOUNT_STATUS,
login.LOGIN_LOGIN_ATTEMPTS,
login.LOGIN_SALT,
GROUP_CONCAT(user_role.USER_ROLE_ROLE SEPARATOR ',') AS ROLES,
user_role.USER_ROLE_STATUS
FROM
login
INNER JOIN
user_role ON user_role.USER_ROLE_USER_ID = login.LOGIN_USER_ID
AND user_role.USER_ROLE_STATUS = @AccStatus
WHERE
login.LOGIN_EMAIL = @UserEmail
AND login.LOGIN_ACCOUNT_STATUS = @AccStatus
AND login.LOGIN_PASSWORD = @PassWD;
如果登录失败,(存在电子邮件,但密码错误)
UPDATE login
SET LOGIN_ACCOUNT_STATUS = (SELECT CASE (LOGIN_LOGIN_ATTEMPTS>@LoginAttempts) WHEN 1 THEN 'LOCKED' ELSE 'ACTIVE' END),
LOGIN_LOGIN_ATTEMPTS = (SELECT CASE (login.LOGIN_USER_ID>1) WHEN 1 THEN LOGIN_LOGIN_ATTEMPTS + 1 ELSE 0 END),
LOGIN_LAST_LOGIN_DATE = @TransactionDateTime,
LOGIN_LAST_LOGIN_LOCATION = null
WHERE LOGIN_EMAIL = @UserEmail;
但是,这失败了,因为我没有将尝试和用户ID存储到变量中。除了使用SET一次读取一个字段外,我不知道该怎么办。既然上面已经读过该表,那么如何提取字段值?