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博客
这篇博客展示了如何使用SQL更新语句,从tp_user表中随机选取未设置头像的用户,并为他们分配不同的头像图片。代码适用于需要随机填充用户头像数据的场景。
11万+

被折叠的 条评论
为什么被折叠?



