当前位置:网站首页>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边栏推荐
- The road of global evolution of vivo global mall -- multilingual solution
- TIOBE - 2022年6月编程语言排行
- LeetCode Algorithm 1791. Find the central node of the star chart
- 2022 blind box applet app has become a new drainage outlet for enterprises
- Machines / scenarios not suitable for webrdp
- Linux(CentOS7)安装MySQL-5.7版本
- Huawei, this is too strong
- 2022年重氮化工艺考试题库模拟考试平台操作
- Simulated 100 questions and simulated examination for safety management personnel of metal and nonmetal mines (small open pit quarries) in 2022
- 联调这夜,我把同事打了...
猜你喜欢

Spiral matrix (skill)

"It's safer to learn a skill!" The little brother of Hangzhou campus changes to software testing, and likes to mention 10k+ weekend!

Redis實現消息隊列的4種方案

Weekly CTF week 1: Amazing tapes

Wechat applet - a case of comparing the size of numbers

Redis cluster + sentinel mode + replicas

Introduction to prism framework - Modular introduction

Recursive and non recursive transformation

redis集群(cluster)+哨兵模式+主从(replicas)

TIOBE - 2022年6月编程语言排行
随机推荐
Program environment and pretreatment
Pyinstaller packaging Exe (detailed tutorial)
Recursive and non recursive transformation
[project training] verification notes
Leetcode 55 jump game
Dataset how to use dataset gracefully. After reading this article, you can fully understand the dataset in c7n/choerodon/ toothfish UI
php安全开发 12博客系统的 系统模块信息的修改
Advantages of Google ads
In 2022, the internal promotion of the "MIHA Tour" golden, silver and silver social recruitment started in April and march! Less overtime, good welfare, 200+ posts for you to choose, come and see!
MP3 to Wav to Midi
Design practice of rongyun Im on electron platform
自适应搜索广告有哪些优势?
Ce soir - là, j'ai battu mon collègue...
华为联运游戏或应用审核驳回:应用检测到支付serviceCatalog:X6
The road of global evolution of vivo global mall -- multilingual solution
为什么我们要使用谷歌搜索广告?
On the night of the joint commissioning, I beat up my colleagues
Software engineering course: Chapter 2 software problem definition and feasibility analysis after class exercises
[project training] wechat official account to obtain user openid
Elementary OJ problem of binary tree