当前位置:网站首页>MySQL表常用操作思维导图
MySQL表常用操作思维导图
2022-06-12 01:44:00 【黑马金牌编程】
mysql基本操作

表操作
主要包括:
查看所有表、表选项、创建表、外键、查看表结构、查看存储引擎状态、查看建表语句、修改表、删除表。

‘
更新数据update
主要包括:更新一个字段、更新多个字段

删除数据delete
删除一行记录、删除所有记录

添加数据insert

数据库操作

查询语句番外篇
浙江大学用户题目回答情况
问题:现在运营想要查看所有来自浙江大学的用户题目回答明细情况,请你取出相应数据
示例: question_practice_detail

示例:user_profile

题解:
先从画像表找到浙江大学的所有学生id列表where university='浙江大学',再去练习明细表筛选出id在这个列表的记录,用where in
select
device_id,question_id,result
from question_practice_detail
where device_id in(
select device_id from user_profile
where university='浙江大学'
)统计每个学校的答过题的用户的平均答题数
问题:运营想要了解每个学校答过题的用户平均答题数量情况,请你取出数据。
图表详情
用户信息表 user_profile,其中device_id指终端编号(认为每个用户有唯一的一个终端),gender指性别,age指年龄,university指用户所在的学校,gpa是该用户平均学分绩点,active_days_within_30是30天内的活跃天数。

答题情况明细表 question_practice_detail,其中question_id是题目编号,result是答题结果。
第一行表示用户的常用信息为使用的设备id为2138,在question_id为111的题目上,回答错误

问题分解:
限定条件:无;
每个学校:按学校分组,group by university
平均答题数量:在每个学校的分组内,用总答题数量除以总人数即可得到平均答题数量count(question_id) / count(distinct device_id)。
表连接:学校和答题信息在不同的表,需要做连接
on条件是在生成临时表时使用的条件
SELECT
university,count(question_id) / count(distinct qpd.device_id) as avg_answer_cnt
from question_practice_detail as qpd
# 使用内连接
inner join user_profile as up
# on条件是在生成临时表时使用的条件
on qpd.device_id=up.device_id
group by university边栏推荐
- Unit tests in golang
- Three times a day (in serial...)
- php安全开发 12博客系统的 系统模块信息的修改
- Four schemes for redis to implement message queue
- Redis cluster + sentinel mode + replicas
- Huawei intermodal game or application review rejected: the application detected payment servicecatalog:x6
- Detailed explanation and examples of common parameters of curl
- LeetCode Algorithm 997. 找到小镇的法官
- You don't need to show your talent. The method is here. You earn 9844 in 31 days as an we media
- 括号生成(回溯)
猜你喜欢

kmeans从0到1

Quatre schémas de mise en file d'attente des messages pour redis

Go language learning summary (7) -- Dachang go programming specification summary

如何让杀毒软件停止屏蔽某个网页?以GDATA为例

决定广告质量的三个主要因素

Four schemes for redis to implement message queue

TIOBE - 2022年6月编程语言排行

Software engineering - system flow chart

【项目实训】校验注解

Introduction to prism framework - Modular introduction
随机推荐
[project training] verification notes
kali安装empire过程中遇到的各种报错解决方案
Several visualization methods of point cloud 3D object detection results (second, pointpillars, pointrcnn)
Bracket generation (backtracking)
Simulated 100 questions and simulated examination for safety management personnel of metal and nonmetal mines (small open pit quarries) in 2022
php开发 博客系统的公告模块的建立和引入
Installing mysql-5.7 for Linux (centos7)
Point cloud perception algorithm interview knowledge points (I)
Colorize Voronoi Diagram Template
"C'est plus sûr d'apprendre une technologie!" Hangzhou Campus Little Brother transfer software test, Hi - Ti 10K + double break!
Weekly CTF week 1: Amazing tapes
PCA from 0 to 1
LeetCode Algorithm 997. Find the town judge
Peewee module basic use -orm
如何最大化的利用各种匹配方式? ——Google SEM
Unit tests in golang
Educational knowledge and ability test questions of primary and secondary school educational endowment examination in the second half of 2019 (middle school) - subjective questions
Simplified interpretation of accuracy and recall in AI papers
Unity頂點動畫的陰影實現
华为联运游戏或应用审核驳回:应用检测到支付serviceCatalog:X6