当前位置:网站首页>SQL quick start
SQL quick start
2022-07-06 16:41:00 【Dog egg L】
Basic query
Query multiple columns
Query statements SELECT Field name FROM Table name ;
answer
select device_id, gender, age, university from user_profile;
Query all columns
* No. is to select all column names
answer :
SELECT * FROM user_profile
Simple processing of query results
Query result de duplication
Go to check again DISTINCT Put it in front of the column name
answer :
SELECT DISTINCT university FROM user_profile
Query results limit the number of rows returned
LIMIT Show the first two lines .
answer :
SELECT device_id FROM user_profile LIMIT 0,2;
Rename the queried column
Change column headings ( Take the alias ) grammar : Name | expression [ AS ] New column names or : New column names = Name | expression
answer :
SELECT device_id as user_infors_example
from user_profile
LIMIT 2
Conditions of the query
Basic sorting
adopt order by Sort :
asc : Ascending
desc : Descending
answer :
select device_id,age
from user_profile
order by age asc;
Sort multiple columns after searching
answer :
SELECT device_id, gpa, age
FROM user_profile
ORDER BY gpa, age;
Sort in descending order after finding
answer :
select device_id,gpa,age
FROM user_profile
ORDER BY gpa desc,age desc
Basic operators
Find the student information of the school is Peking University
stay where Add the condition as ‘ Peking University, ’ that will do .
answer :
select device_id,university
from user_profile
where university=' Peking University, '
Look for ages greater than 24 Years old user information
answer :
select device_id,gender,age,university from user_profile
where age>24
Find user information for a certain age group
Determine scope use BETWEEN…AND and NOT BETWEEN…AND Is a logical operator , It can be used to find tuples whose attribute values are or are not within the specified range , among BETWEEN The lower limit of the specified range at the back ,AND The upper limit of the range specified later .BETWEEN…AND… The format is : Name | expression [ NOT ] BETWEEN Lower limit AND Upper limit value
answer :
select device_id,gender,age
FROM user_profile
WHERE age>=20 and age<=23
Find user information except Fudan University
answer :
select device_id, gender, age, university
from user_profile
where university != ' Fudan University '
use where Filter null exercises
answer :
SELECT `device_id`,`gender`,`age`,`university`
from user_profile
where not age is NULL
边栏推荐
- Install Jupiter notebook under Anaconda
- 去掉input聚焦时的边框
- Summary of game theory
- sublime text 代码格式化操作
- useEffect,函数组件挂载和卸载时触发
- Research Report on market supply and demand and strategy of China's four flat leadless (QFN) packaging industry
- Advancedinstaller installation package custom action open file
- Codeforces Round #799 (Div. 4)A~H
- Raspberry pie 4b64 bit system installation miniconda (it took a few days to finally solve it)
- Codeforces Round #801 (Div. 2)A~C
猜你喜欢
QT realizes window topping, topping state switching, and multi window topping priority relationship
拉取分支失败,fatal: ‘origin/xxx‘ is not a commit and a branch ‘xxx‘ cannot be created from it
QT implementation window gradually disappears qpropertyanimation+ progress bar
Spark independent cluster dynamic online and offline worker node
SQL快速入门
ffmpeg命令行使用
Story of [Kun Jintong]: talk about Chinese character coding and common character sets
antd upload beforeUpload中禁止触发onchange
第7章 __consumer_offsets topic
Oneforall installation and use
随机推荐
Research Report of desktop clinical chemical analyzer industry - market status analysis and development prospect prediction
Chapter 1 overview of MapReduce
SQL快速入门
Browser print margin, default / borderless, full 1 page A4
Raspberry pie 4B installation opencv3.4.0
Research Report on market supply and demand and strategy of Chinese table lamp industry
Simply try the new amp model of deepfacelab (deepfake)
Li Kou - 298th weekly match
第五章 Yarn资源调度器
Research Report on hearing health care equipment industry - market status analysis and development prospect prediction
Codeforces Round #799 (Div. 4)A~H
Solve the problem that intel12 generation core CPU single thread only runs on small cores
Spark's RDD (elastic distributed data set) returns a large result set
视频压缩编码和音频压缩编码基本原理
Codeforces Round #797 (Div. 3)无F
Calculate the time difference
图像处理一百题(11-20)
Tert butyl hydroquinone (TBHQ) Industry Research Report - market status analysis and development prospect forecast
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Installation and configuration of MariaDB