松鼠短视频系统为用户加入随机头像代码-快速为用户加上随机头衔

这篇博客展示了如何使用SQL更新语句,从tp_user表中随机选取未设置头像的用户,并为他们分配不同的头像图片。代码适用于需要随机填充用户头像数据的场景。
update tp_user
set head_img='图片1'
where id IN(
select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='图片2'
where id IN(
select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='图片3'
where id IN(
select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);

以上代码执行即可,此前写了蜻蜓q系统如何随机加入头像,由于松鼠短视频字段不同因此也列一个方便大家使用。

自己使用记录:

update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270837516589514941.png'
where id IN(
select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270835149436524711.png'
where id IN(
    select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270834429074265079.png'
where id IN(
    select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270836314036839413.png'
where id IN(
select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270836157965414975.png'
where id IN(
    select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);
update tp_user
set head_img='http://qingtingcun.youyacao.com/qiniu_202110270835431933928235.png'
where id IN(
    select A.* from(select id from tp_user where head_img='' order by rand() limit 10) AS A
);

此前相关文章

数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir_~央千澈~的博客-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卓伊凡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值