mysql,在phpmyadmin的SQL命令行下如何生成10条随机字母组合的用户名

mysql,在phpmyadmin的SQL命令行下如何生成10条随机字母组合的用户名,第1张

select concat(

char(round((rand())*25)+97),

char(round((rand())*25)+65),

char(round((rand())*25)+65),

char(round((rand())*25)+65),

char(round((rand())*25)+65)

)

---------

+97就是产生小写字母a-z

+65就是产生大写字母A-Z

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

这是一条的。

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

insert into user (username) value (concat(char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97), char(floor(rand()*26)+97)))

把一条的复制十次,这就是十条的。

按长度排序的方法:

select *,len(id) len_id from image where title like '%XXXX%' order by len_id desc

union不能使用order,你这样的需求应该是把两次查询的结果保存到临时表里面,然后从临时表里面获数据。使用临时表的方法能方便的实现去除重复。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8645208.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-19
下一篇 2023-04-19

发表评论

登录后才能评论

评论列表(0条)

保存