当前位置:网站首页>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
边栏推荐
- Codeforces Round #800 (Div. 2)AC
- How to insert mathematical formulas in CSDN blog
- Tree of life (tree DP)
- Spark独立集群动态上线下线Worker节点
- Codeforces Round #798 (Div. 2)A~D
- 第五章 Yarn资源调度器
- Chapter 7__ consumer_ offsets topic
- 日期加1天
- QT implementation window gradually disappears qpropertyanimation+ progress bar
- Chapter 6 datanode
猜你喜欢
随机推荐
China double brightening film (dbef) market trend report, technical dynamic innovation and market forecast
Educational Codeforces Round 122 (Rated for Div. 2)
Summary of game theory
Classic application of stack -- bracket matching problem
图图的学习笔记-进程
FLV格式详解
图像处理一百题(1-10)
Chapter 7__ consumer_ offsets topic
第三章 MapReduce框架原理
Discussion on QWidget code setting style sheet
China tetrabutyl urea (TBU) market trend report, technical dynamic innovation and market forecast
QT implementation window gradually disappears qpropertyanimation+ progress bar
原生js实现全选和反选的功能 --冯浩的博客
(lightoj - 1369) answering queries (thinking)
Chapter 5 detailed explanation of consumer groups
两个礼拜速成软考中级软件设计师经验
Solve the problem that intel12 generation core CPU single thread only runs on small cores
Summary of FTP function implemented by qnetworkaccessmanager
顺丰科技智慧物流校园技术挑战赛(无t4)
OneForAll安装使用








