当前位置:网站首页>数据库进阶·如何针对所有用户数据中没有的数据去加入随机的数据-蜻蜓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行被影响说明所有用户都已经加上头像了。

边栏推荐
- Redisv6.0为何引入多线程?
- 【汇编语言01】基础知识
- Share | intelligent fire emergency management platform solution (PDF attached)
- 文件无法保存(文件夹已损坏无法读取怎么办)
- Automatic assembly and fuse degradation of feign
- Animation curves are used every day. Can you make one by yourself? After reading this article, you will!
- [51nod1676 undirected graph isomorphism] undirected graph hash [easy to understand]
- [fan Tan] those stories that seem to be thinking of the company but are actually very selfish (I: building wheels)
- 信息安全建设原则指导
- How to quickly build a picture server [easy to understand]
猜你喜欢

Redis基础2(笔记)

Share | intelligent fire emergency management platform solution (PDF attached)

JMeter websocket接口测试
![[go basics 02] the first procedure](/img/af/f32762a828f384bf6aa063ebf959aa.png)
[go basics 02] the first procedure

Whether the five distribution methods will produce internal fragments and external fragments

成为比开发硬气的测试人,我都经历了什么?

Jmeter--- set proxy recording request

开源的RSS订阅器FreshRSS

2022 the latest software tests eight part essay. Whether you can offer depends on how you recite it

Redis usage details
随机推荐
2022 love analysis ― bank digitalization practice report
手机端微信发朋友圈功能测试点总结
[leetcode ladder] linked list · 876 find the middle node of the linked list
Guys, how can Flink SQL submit tasks in per job mode?
Redis memory elimination mechanism?
dovecot 设置邮箱quota
开源的RSS订阅器FreshRSS
Configuration and use of multithreading
C language: random generated number + bubble sort
虚拟内存与磁盘
Acwing 866. determining prime numbers by trial division
面了个腾讯三年经验的测试员,让我见识到了真正的测试天花板
[51Nod1676 无向图同构]无向图哈希[通俗易懂]
Dovecot set mailbox quota
Ability to choose
Why do independent sellers like to do e-mail marketing? The original conversion rate can be improved so much!
Bitcoin.com:usdd represents a truly decentralized stable currency
GPON introduction and Huawei OLT gateway registration and configuration process
Create EDA - why should I learn EDA
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?