+ -
当前位置:首页 → 问答吧 → MYSQL中插入某几位固定的随机字符串,望高手给于解答

MYSQL中插入某几位固定的随机字符串,望高手给于解答

时间:2008-09-19

来源:互联网

用户被禁言,该主题自动屏蔽!

作者: sandyboy1001   发布时间: 2008-09-19

没人么...好几天了

作者: fcvy   发布时间: 2008-09-19

用户被禁言,该主题自动屏蔽!

作者: wx8052   发布时间: 2008-09-19

mysql 生成随机字符串


select concat(
char(round((rand())*25)+97),
char(round((rand())*25)+65),
char(round((rand())*25)+65),
char(round((rand())*25)+97),
char(round((rand())*25)+65),
char(round((rand())*25)+65),
char(round((rand())*25)+97),
char(round((rand())*25)+65)
)

---------

+97就是产生小写字母a-z
+65就是产生大写字母A-Z

结果不包含其他字符

作者: 织羽   发布时间: 2008-09-19

select concat(
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end,
case when round((rand())*25) > 12 then char(round((rand())*25)+97) else char(round((rand())*25)+65) end
) as keka

也可用 case when 再混淆大小写。

作者: ever66   发布时间: 2008-09-19