当前位置:网站首页>SQL language learning record I
SQL language learning record I
2022-07-01 06:35:00 【Small dollar】
sql The classification of languages
DDL( Data definition language ):CREATE\ALTER\DROP\RENAME\TURNCATE
DML( Data operation language );INSERT\DELETE\UPDATE\SELECT
DCL( Control language ):COMMIT\ROLLBACK\SAVEPOINT\GRANT\REVOKE
sql Rules and norms of language :
The rules :
1\ Three ways of annotation
/* */ Multiline comment
– notes
"#" Also a note
2、 Import an existing data table
1.source File path
2. Graphical interface
show databases Display database
source route
use atguigudb;
show tables
There are three ways to alias columns
SELECT employ_id emp_id FROM employee
Add sa
quotation marks
DISTINCT
select distinct department_id from employee
Remove duplicate data
Null operation
The result of null value participating in the operation is also null Therefore, a null value is not “null” Nor is it. 0
SELECT employee_id,salary,salary * IFNULL(( 1 + commission_pct),0) * 12 as Annual wage FROM employees;
mark of emphasis
If it indicates that the name is the same as the keyword, you need to add “ `` ” To restore normal operation
DESCRIVE
Display table structure describe employees;
DESC employees;
Filter conditions
Inquire about 90 Employee information of department No
select * from employeee where name = ‘king’
Single quotation marks mysql Case sensitive ,ocrale Case sensitive
+ - * / div % mod
- SELECT 100 + ‘1’ FROM DUAL; We found out it was 101
java The result is 1001,sql Middle means addition operation ( Implicit conversion )- SELECT 100 + ‘a’ FROM DUAL; At this time will be a regard as 0 To deal with it
Comparison operator
<=> Safety is equal to
<> It's not equal to
character string ‘a’ Be regarded as 0 Value
If you compare a pure string with a string, you won't implicitly convert a value
As long as there is null The result of participation is null, If the value to be queried is null Data should use security equal to
IS NULL \IS NOT NULL \ ISNULL
WHERE ISNULL(commission_pct);
where comminssion_pct <=> null
where not commission_pct <=> null;
least \greatest
in
SELECT department_id ,last_name from employees WHERE department_id in (10,20,30);
The query department number is 10,20,30 People's information
like
SELECT last_name FROM employees where last_name like ‘%a%’;
The percent sign represents an indefinite number of characters (0 individual 1 More than one )
SELECT last_name FROM employees where last_name like ‘a%’;
With a Start character
Contains characters a And contains characters e Of
SELECT last_name FROM employees where last_name like ‘%a%e%’ or last_name like “%e%a%”;
contain e And contains a The data of
- _ The second character is a
SELECT last_name FROM employees where last_name like ‘__a%’;
Logical operators
or || and
And && or
and Has a higher priority than or The priority of the
Priority can be perfect without adding parentheses
The sorting operation
If there is no sorting, it is implemented in the order of addition by default
Use orderby Sort the order found
Ascending :asc By default, it is arranged in ascending order from low to high
Descending :desc
SELECT employee_id,salary from employees ORDER BY salary desc;
Column aliases can only be used in orderby Cannot be used in where Use in
Pagination
SELECT * FROM employees
LIMIT 0,20
Paged display from 0 Start the first 20 Data
Display the data on the second page
limit 20,20
边栏推荐
- B-tree series
- Application of IT service management (ITSM) in Higher Education
- 码力十足学量化|如何在财务报告寻找合适的财务公告
- [wechat applet] to solve button, input and image components
- HW(OD)岗面试题
- 【#Unity Shader#自定义材质面板_第一篇】
- 树莓派4的WiFi设置
- Camouflage request header Library: Anti useragent
- Postgraduate entrance examination directory link
- DSBridge
猜你喜欢

SQL语句

Idea easy to use plug-in summary!!!

产品学习(二)——竞品分析
![[ManageEngine] how to realize network automatic operation and maintenance](/img/8a/75332d3180f92c6a6482d881032bbf.png)
[ManageEngine] how to realize network automatic operation and maintenance

C语言课设职工信息管理系统(大作业)

下载外文期刊的方法

NOC 设计的一些坑

Picture server project test

C language course set up salary management system (big homework)

Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb
随机推荐
软件工程复习
[unity shader custom material panel part I]
产品学习(一)——结构图
2022 年江苏省职业院校技能大赛(中职) 网络搭建与应用赛项公开赛卷
DML statement in SQL (data operation language)
Promise
Several ways of gson's @jsonadapter annotation
async 与 await
VS2019如何永久配置本地OpenCV4.5.5使用
Async and await
Grain Mall - environment (p1-p27)
[ManageEngine Zhuohao] the role of LAN monitoring
Redis安装到Windows系统上的详细步骤
How to use SCI hub
SQL learning notes 2
树莓派4的WiFi设置
问题:OfficeException: failed to start and connect(三)
Is the account opening of Huafu securities safe and reliable? How to open Huafu securities account
C语言课设学生考勤系统(大作业)
常用快捷键