当前位置:网站首页>数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir
数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir
2022-07-25 22:02:00 【~央千澈~】
数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓Q系统用户没有头像如何加入头像数据-优雅草科技kir
本内容主要用于学习,头像只是举例的一个字段,可以应用在其他方面,举一反三
问题背景:
蜻蜓q旗舰版是根据手机设备信息自动分配用户账号并登陆,跳过了用户注册上传头像步骤,因此大量用户没有头像,

此时需要给这些用户添加上随机的头像整理以下运行语句:
update users
set avatar='http://qingtingcun.youyacao.com/qiniu_202110270837150713870048.png'
where id IN(
select A.* from(select id from users where avatar='' order by rand() limit 10) AS A
);这段语句是每次随机找出10条没有头像的进行更新为指定头像地址:
http://qingtingcun.youyacao.com/qiniu_202110270837150713870048.png
那么如果我们要随机更新不同的几个头像那么代码则为
update users
set avatar='图片1'
where id IN(
select A.* from(select id from users where avatar='' order by rand() limit 10) AS A
);
update users
set avatar='图片2'
where id IN(
select A.* from(select id from users where avatar='' order by rand() limit 10) AS A
);
update users
set avatar='图片3'
where id IN(
select A.* from(select id from users where avatar='' order by rand() limit 10) AS A
);诸如此就是随机更新为这三个头像,以此类推,如果多放几个头像多执行几次很快就ok了。

效果

多执行几次,直到提示有0行被影响说明所有用户都已经加上头像了。

边栏推荐
- Bitcoin.com:USDD代表了真正去中心化稳定币
- The technical aspects of ByteDance are all over, but the result is still brushed. Ask HR why...
- 【饭谈】细说:下克上,向上管理,向上画饼。
- Bitcoin.com:usdd represents a truly decentralized stable currency
- All you want to know about interface testing is here
- Share | intelligent fire emergency management platform solution (PDF attached)
- 2 lines of code to generate a solid desktop background
- Lichuang EDA -- creation of devices 01 resistance (II)
- C语言游戏 双缓存解决闪屏问题 详细总结[通俗易懂]
- [hand tear STL] BitSet (bitmap), bloom filter
猜你喜欢

2 lines of code to generate a solid desktop background
![[redis underlying parsing] linked list type](/img/e8/c192629dce1a958155a562d216d532.png)
[redis underlying parsing] linked list type
![[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality](/img/11/42c4674d23ee93850fb3d2de0d0932.png)
[dinner talk] those things that seem to be for the sake of the company but are actually incomprehensible (2: soft quality "eye edge" during interview)

关于接口测试你想知道的都在这儿了

在腾讯干软件测试3年,7月无情被辞,想给划水的兄弟提个醒...

Jmeter---设置代理录制请求

6-17漏洞利用-反序列化远程命令执行漏洞

核电站在席卷欧洲的热浪中努力保持安全工作

信息安全建设原则指导

字节跳动技术面都过了,结果还是被刷了,问HR原因竟是。。。
随机推荐
C语言左值和右值说明[通俗易懂]
YUV420 YUV420sp 图像格式「建议收藏」
How to implement distributed locks with redis?
立创EDA——我为什么要学EDA
c sqlite ... ...
[hand tear STL] BitSet (bitmap), bloom filter
Basic knowledge in the project
Shopify sellers: share some tips for social media marketing!
Acwing 866. determining prime numbers by trial division
JSP初识
sql语句练习题整理
The automation testing post spent 20K recruiting, but in the end, there was no suitable one. Both fresh students are better than them
JSP novice
如何实现一个App应用程序,限制用户时间使用?
Create files, file permissions, ownership, and sticky bits
Come again
Whether the five distribution methods will produce internal fragments and external fragments
核电站在席卷欧洲的热浪中努力保持安全工作
Children's programming electronic society graphical programming level examination scratch level 1 real problem analysis (judgment question) June 2022
[fan Tan] in detail: lower control, upward management, upward drawing cake.