当前位置:网站首页>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
边栏推荐
- QT style settings of qcobobox controls (rounded corners, drop-down boxes, up expansion, editable, internal layout, etc.)
- Summary of FTP function implemented by qnetworkaccessmanager
- Anaconda下安装Jupyter notebook
- QT implementation window gradually disappears qpropertyanimation+ progress bar
- It is forbidden to trigger onchange in antd upload beforeupload
- Click QT button to switch qlineedit focus (including code)
- Market trend report, technological innovation and market forecast of China's double sided flexible printed circuit board (FPC)
- SQL快速入门
- 力扣——第298场周赛
- 力扣leetcode第 280 场周赛
猜你喜欢
随机推荐
Spark的RDD(弹性分布式数据集)返回大结果集
Advancedinstaller installation package custom action open file
Remove the border when input is focused
Market trend report, technical innovation and market forecast of China's desktop capacitance meter
生成随机密码/验证码
图像处理一百题(1-10)
解决Intel12代酷睿CPU单线程调度问题(二)
第2章 HFDS的Shell操作
Codeforces Round #803 (Div. 2)A~C
力扣leetcode第 280 场周赛
Simple records of business system migration from Oracle to opengauss database
China double brightening film (dbef) market trend report, technical dynamic innovation and market forecast
Market trend report, technical innovation and market forecast of double-sided foam tape in China
Codeforces Round #799 (Div. 4)A~H
It is forbidden to trigger onchange in antd upload beforeupload
Calculate the time difference
【锟斤拷】的故事:谈谈汉字编码和常用字符集
QT simulates mouse events and realizes clicking, double clicking, moving and dragging
Research Report on market supply and demand and strategy of China's four flat leadless (QFN) packaging industry
Local visualization tools are connected to redis of Alibaba cloud CentOS server









