要实现的功能是,如果数据库中有值那么就从新生成一个,如果没有直接使用代码如下:
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的存储过程大家帮看下有语法问题没,现在总是在插入的过程中出现重复提示,所以我觉得应该是这个存储过程什么地方有问题了。
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的存储过程大家帮看下有语法问题没,现在总是在插入的过程中出现重复提示,所以我觉得应该是这个存储过程什么地方有问题了。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货