# 随机生成六位数验证码
SELECT lpad(ROUND(RAND()*1000000,0),6,0) AS '随机验证码';
SELECT RAND();生成随机小数;
SELECT ROUND(小数,保留几位小数);
SELECT LPAD(需要填充的数,需要填充几位,填充什么(int || string));向左填充
也可以向右填充:
SELECT RPAD(ROUND(RAND()*1000000,0),6,0) AS '随机验证码';
# 随机生成六位数验证码
SELECT lpad(ROUND(RAND()*1000000,0),6,0) AS '随机验证码';
SELECT RAND();生成随机小数;
SELECT ROUND(小数,保留几位小数);
SELECT LPAD(需要填充的数,需要填充几位,填充什么(int || string));向左填充
也可以向右填充:
SELECT RPAD(ROUND(RAND()*1000000,0),6,0) AS '随机验证码';