当前位置:网站首页>SQL 练习(一)
SQL 练习(一)
2022-04-23 11:56:00 【抄代码抄错的小牛马】
目录
学习SQL有段时间了,想要更加熟练的掌握它,那就只有刷题咯~~~
-
SQL篇之非技术快速入门
-
基础查询
-
查询所有列
代码:select 语句
select * from user_profile
-
查询多列
代码:从表中select出:设备ID,性别,年龄学校列名就OK
select device_id,gender,age,university --设备ID,性别,年龄学校
from user_profile
-
查询结果去重
代码:distinct 去重
select distinct university
FROM user_profile
-
查询结果限制返回行数
代码:where条件查询
select device_id
from user_profile
where id<=2
- 将查询后的列重新命名
代码:as重命名,重命名还有:
select device_id as user_infos_example
from user_profile
where id<=2
-
条件查询
- 查找后排序
代码:order by 列名 asc/desc asc 升序,desc 降序,默认排序为升序
select device_id,age from user_profile order by age
-
查找后多列排序
代码:
select device_id, gpa, age from user_profile
order by gpa asc, age asc
- 查找后降序排列
代码:desc 降序排列
select device_id,gpa,age
from user_profile
order by gpa desc,age desc
-
查找学校是北大的学生信息
代码:where 语句条件查询
select device_id,university
from user_profile
where university='北京大学'
-
查找年龄大于24的用户
代码:
select device_id,gender,age,university
from user_profile
where age>24
-
查找某个年龄段的用户信息
代码:and并列条件
select device_id,gender,age
from user_profile
where age>=20 and age<=23
-
查找除复旦大学的用户信息
代码:!= 不等于
select device_id, gender, age, university
from user_profile
where university != '复旦大学'
-
用where过滤空值练习
代码:
select device_id,gender,age,university
from user_profile
where age !=' '
版权声明
本文为[抄代码抄错的小牛马]所创,转载请带上原文链接,感谢
https://yuanxinghua.blog.csdn.net/article/details/124336436
边栏推荐
- Database design of forum system
- Nacos Foundation (7): Configuration Management
- IFLYTEK's revenue in 2021 was 18.3 billion yuan: a year-on-year increase of 41% and a net profit of 1.556 billion yuan
- 科创人·派拉软件CEO谭翔:零信任本质是数字安全,To B也要深研用户心智
- 第五章 使用In-Memory表达式优化查询(IM 5.1)
- Significance of actively participating in middle school robot competition
- 用户接口和IM表达式(IM 5.6)
- oh-my-lotto
- 论文解读(CGC)《CGC: Contrastive Graph Clustering for Community Detection and Tracking》
- VMware虚拟机使用esxi 导出硬盘vmdk文件
猜你喜欢
On lambda powertools typescript
Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
After a circle, I sorted out this set of interview questions..
IDEA 代码格式化插件Save Actions
魔域来了H5游戏详细图文架设教程
激活函数之relu函数
亿级流量架构,服务器如何扩容?写得太好了!
激活函数之sigmoid函数
Sigmoid function of activation function
VMware virtual machines export hard disk vmdk files using esxi
随机推荐
Redis optimization series (II) redis master-slave principle and master-slave common configuration
The fourth chapter is about enabling and disabling the im column storage of table space for im enabled filling objects (IM 4.5)
Im architecture: CPU architecture: SIMD vector processing (im-2.3)
魔域来了H5游戏详细图文架设教程
2022 love analysis · panoramic report of industrial Internet manufacturers
Purpose of IM expression (IM 5.2)
ImportError: libX11.so.6: cannot open shared object file: No such file or directory
IDEA 代码质量规范插件SonarLint
The way to change children's programming structure
Next.js 静态数据生成以及服务端渲染的方式
Nacos Foundation (9): Nacos configuration management from single architecture to microservices
Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
Interpretation 3 of gdpr series: how do European subsidiaries return data to domestic parent companies?
Master slave replication configuration of MySQL
《通用数据保护条例》(GDPR)系列解读三:欧洲子公司如何向国内母公司回传数据?
第四章 为物化视图启用和禁用IM列存储(IM 4.6)
论坛系统数据库设计
Chapter 4 specifies the attribute of the inmemory column on the no inmemory table for im enabled filling objects: examples (Part IV of im-4.4)
Analyze the rules for the use of robots with good performance
The fourth chapter is to enable the filling object of IM and enable ADO for im column storage (IM 4.8)