我有一个mysql存储过程需要验证输入字母数字的密码输入,并且不接受少于8个字符。但是,当我测试它时,它甚至可以接受1个字符。我试图改善验证。希望有所了解。
提前谢谢你:
以下是该脚本的一部分:
PREPARE STMT1 FROM " SELECT COUNT(column1) INTO @1 FROM table where column2 = ? ";
SET @a = x;
EXECUTE STMT1 USING @a;
DEALLOCATE PREPARE STMT1;
START TRANSACTION;
IF @1 = 6 THEN
PREPARE STMT1 FROM "DELETE FROM table WHERE column2 = ? ORDER BY seqid LIMIT 1";
SET @a = x;
EXECUTE STMT1 USING @a;
DEALLOCATE PREPARE STMT1;
END IF;
PREPARE STMT FROM " UPDATE table2 SET column3 = sha1(BINARY ?),column4 = now() WHERE column2 = ? ";
SET @a = newpassword;
SET @b = x;
EXECUTE STMT USING @a,@b;
DEALLOCATE PREPARE STMT;
PREPARE STMT1 FROM " INSERT INTO table2 (column1,column2,column3) VALUES (?,sha1(BINARY ?),now())";
SET @a = x;
SET @b = newpassword;
EXECUTE STMT1 USING @a,@b;
答案 0 :(得分:0)
您似乎正在尝试使用COUNT(col)
来确定密码的长度。
您想要CHARACTER_LENGTH(col)
。 https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length