+ -
当前位置:首页 → 问答吧 → mysql随机生成字符问题

mysql随机生成字符问题

时间:2011-07-12

来源:互联网

要实现的功能是,如果数据库中有值那么就从新生成一个,如果没有直接使用代码如下:
SQL code
SET u = rand_string(4);
select username into temp from t_user where username=concat('\"',u,'\"');
 if(temp != "") then
  set u = rand_string(4);
  while(temp=u) do
  select temp;
  set u = rand_string(4);
  select username into temp from t_user where username=concat('\"',u,'\"');
  select u;
end while;
end if;


这是mysql的存储过程大家帮看下有语法问题没,现在总是在插入的过程中出现重复提示,所以我觉得应该是这个存储过程什么地方有问题了。

作者: icecoldheart   发布时间: 2011-07-12

rand_string(4)是获取4位随机数

作者: icecoldheart   发布时间: 2011-07-12

相关阅读 更多

热门下载

更多