我遇到了问题:我想在if子句
中使用此查询的结果SELECT COUNT(*)
FROM user
WHERE userid = 1234 AND password = 1234;
这个概念在我的伪代码中是这样的 - 我不知道该怎么做
if (count = 0) {
SELECT logintattempt
INTO @temp
FROM user
WHERE userid = 1234
SELECT (@temp+1) INTO @temp
}
SELECT loginattempt
FROM user
WHERE userid = 1234;
if(loginattempt >= 3) {
UPDATE user
SET status = 'blocked'
WHERE userid = 1234;
}
如果计数为0,则登录尝试将增加,当登录尝试次数超过3时,将执行更新状态为已阻止
答案 0 :(得分:0)
根据我的理解,您想知道如何使用
的结果SELECT COUNT(*) FROM user WHERE userid=1234 AND password=1234;
进入if语句。这是你做的:
SET @count:= (SELECT COUNT(*) FROM user WHERE userid=1234 AND password=1234);
SELECT @count;
这有帮助吗?