当前位置:网站首页>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
边栏推荐
- Tree of life (tree DP)
- sublime text 代码格式化操作
- AcWing——第55场周赛
- Market trend report, technological innovation and market forecast of China's double sided flexible printed circuit board (FPC)
- 去掉input聚焦时的边框
- Codeforces Round #803 (Div. 2)A~C
- 视频压缩编码和音频压缩编码基本原理
- Submit several problem records of spark application (sparklauncher with cluster deploy mode)
- Codeforces Round #800 (Div. 2)AC
- Codeforces Round #797 (Div. 3)无F
猜你喜欢

SF smart logistics Campus Technology Challenge (no T4)

Chapter 5 namenode and secondarynamenode

第2章 HFDS的Shell操作

QT realizes window topping, topping state switching, and multi window topping priority relationship

Codeforces Round #802(Div. 2)A~D

Problem - 922D、Robot Vacuum Cleaner - Codeforces

拉取分支失败,fatal: ‘origin/xxx‘ is not a commit and a branch ‘xxx‘ cannot be created from it

第6章 DataNode

第5章 消费者组详解

(lightoj - 1369) answering queries (thinking)
随机推荐
SF smart logistics Campus Technology Challenge (no T4)
Raspberry pie 4B installation opencv3.4.0
图像处理一百题(1-10)
Acwing: Game 58 of the week
Chapter 5 yarn resource scheduler
第5章 NameNode和SecondaryNameNode
Codeforces Round #803 (Div. 2)A~C
Click QT button to switch qlineedit focus (including code)
AcWing——第55场周赛
Chapter 5 namenode and secondarynamenode
Li Kou - 298th weekly match
useEffect,函數組件掛載和卸載時觸發
Problem - 922D、Robot Vacuum Cleaner - Codeforces
视频压缩编码和音频压缩编码基本原理
js封装数组反转的方法--冯浩的博客
Hbuilder X格式化快捷键设置
Codeforces Round #801 (Div. 2)A~C
useEffect,函数组件挂载和卸载时触发
字节跳动新程序员成长秘诀:那些闪闪发光的宝藏mentor们
Chapter 6 datanode