当前位置:网站首页>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
边栏推荐
- 简单尝试DeepFaceLab(DeepFake)的新AMP模型
- Codeforces - 1526C1&&C2 - Potions
- FLV格式详解
- It is forbidden to trigger onchange in antd upload beforeupload
- Chapter 5 detailed explanation of consumer groups
- (POJ - 3186) treatments for the cows (interval DP)
- Chapter 5 namenode and secondarynamenode
- Codeforces Round #797 (Div. 3)无F
- 使用jq实现全选 反选 和全不选-冯浩的博客
- Problem - 1646C. Factorials and Powers of Two - Codeforces
猜你喜欢
图像处理一百题(11-20)
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Solve the single thread scheduling problem of intel12 generation core CPU (II)
第三章 MapReduce框架原理
Installation and configuration of MariaDB
Discussion on QWidget code setting style sheet
Solve the problem that intel12 generation core CPU single thread only runs on small cores
Raspberry pie 4b64 bit system installation miniconda (it took a few days to finally solve it)
Spark independent cluster dynamic online and offline worker node
使用jq实现全选 反选 和全不选-冯浩的博客
随机推荐
(lightoj - 1354) IP checking (Analog)
第一章 MapReduce概述
QT style settings of qcobobox controls (rounded corners, drop-down boxes, up expansion, editable, internal layout, etc.)
Codeforces Global Round 19
Generate random password / verification code
Problem - 1646C. Factorials and Powers of Two - Codeforces
875. Leetcode, a banana lover
Browser print margin, default / borderless, full 1 page A4
Business system compatible database oracle/postgresql (opengauss) /mysql Trivia
Research Report on market supply and demand and strategy of China's four flat leadless (QFN) packaging industry
Install Jupiter notebook under Anaconda
Codeforces round 797 (Div. 3) no f
<li>圆点样式 list-style-type
字节跳动新程序员成长秘诀:那些闪闪发光的宝藏mentor们
浏览器打印边距,默认/无边距,占满1页A4
Codeforces Round #799 (Div. 4)A~H
(lightoj - 1370) Bi shoe and phi shoe (Euler function tabulation)
拉取分支失败,fatal: ‘origin/xxx‘ is not a commit and a branch ‘xxx‘ cannot be created from it
Li Kou: the 81st biweekly match
Submit several problem records of spark application (sparklauncher with cluster deploy mode)