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

边栏推荐
- Mouseevent event -- mouse coordinate description -- Focus event -- input event -- throttle -- mousewheel (wheel event)
- [test development methodology] experience of test development platform PK - choice
- 【饭谈】如何设计好一款测试平台?
- [assembly language 01] basic knowledge
- [51nod1676 undirected graph isomorphism] undirected graph hash [easy to understand]
- 文件无法保存(文件夹已损坏无法读取怎么办)
- [fan Tan] in detail: lower control, upward management, upward drawing cake.
- Guiding principles of information security construction
- Guys, how can Flink SQL submit tasks in per job mode?
- PE format: analyze and implement IATHOOK
猜你喜欢

Origen foundation officially launched $ogy stacking, leading a new round of ecological benefits

2年功能测试,却感觉自己什么都不会,2022我该何去何从?

立创EDA——我为什么要学EDA

Why do independent sellers like to do e-mail marketing? The original conversion rate can be improved so much!

Open source RSS subscriber freshrss

Three ways to allocate disk space

『Skywalking』.NET Core快速接入分布式链路追踪平台
![[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)

Redis 使用详解

Basic knowledge in the project
随机推荐
[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决
YUV420 YUV420sp 图像格式「建议收藏」
Whether the five distribution methods will produce internal fragments and external fragments
How to solve the problem of using the download Plug-in for export?
Detailed summary of C language game dual cache to solve the flash screen problem [easy to understand]
c sqlite ... ...
Lichuang EDA -- creation of devices 01 resistance (II)
[51Nod1676 无向图同构]无向图哈希[通俗易懂]
Uninstall NPM and install NPM_ Use 'NPM uninstall' to uninstall the NPM package 'recommended collection'
Redis usage details
What is redis? Briefly describe its advantages and disadvantages
Composition of dog food
在腾讯干软件测试3年,7月无情被辞,想给划水的兄弟提个醒...
Create EDA - why should I learn EDA
虚拟内存与磁盘
Basic knowledge in the project
El expression improves JSP
『Skywalking』.NET Core快速接入分布式链路追踪平台
[redis underlying parsing] string type
redis主从架构锁失效问题(主从)