当前位置:网站首页>Review of MySQL (VI): usage of Union and limit
Review of MySQL (VI): usage of Union and limit
2022-06-12 18:20:00 【BKSW.】
MySql Review ( 6、 ... and ):Union and Limit Usage of
union
union You can merge collections ( Add up )
- use or
select ename,job from emp where job = 'MANAGER' or job = 'SALESMAN';

- Inquire about job contain MANAGER And contains SALESMAN The employees'
select * from emp where job in('MANAGER', 'SALESMAN');
- use union To merge
select * from emp where job='MANAGER'
union
select * from emp where job='SALESMAN';

The spliced data must correspond to each other . A table cannot be a data , The other table is two data , This cannot be spliced !
limit( a key )
It is mainly used to extract the first or middle rows of data ,limit yes mysql Peculiar , There are no other databases , Not universal .(Oracle There's the same mechanism in , be called rownum)
Grammatical mechanism :
limit startIndex, length
startIndex Indicates the starting position , from 0 Start ,0 Represents the first data .
length Take a few
Case study : Before taking out the salary 5 A great employee ( Ideas : Before descending 5 individual )
select ename,sal from emp order by sal desc;
Take before 5 individual :
select ename,sal from emp order by sal desc limit 0, 5;
select ename,sal from emp order by sal desc limit 5;
Get the first five data
select * from emp limit 5;

Take two pieces of data from the second one
select * from emp limit 1,2;

Before getting the highest salary 5 name
select * from emp e order by e.sal desc limit 5;
Find the fourth to ninth highest paid employees
select ename,sal from emp order by sal desc limit 3,6;
On the page
- limit yes sql The last step in the execution of a statement :
select 5
...
from 1
...
where 2
...
group by 3
...
having 4
...
order by 6
...
limit 7
...;
- Common standard paging
Each page shows 3 Bar record :
The first 1 page :0, 3
The first 2 page :3, 3
The first 3 page :6, 3
The first 4 page :9, 3
The first 5 page :12, 3
Each page shows pageSize Bar record :
The first pageNo page :(pageNo - 1) * pageSize, pageSize
pageSize What is it? ? It's how many records are displayed per page
pageNo What is it? ? Show the page
java Code {
int pageNo = 2; // The page number is 2
int pageSize = 10; // Each page shows 10 strip
limit (pageNo - 1) * pageSize, pageSize
}
边栏推荐
- Introduction to reinforcement learning and analysis of classic items 1.3
- Random talk about redis source code 90
- Gd32f4xx controls dgus variable display
- Summary of static memory allocation and dynamic memory allocation
- C brief introduction
- TypeScript类型声明文件(三)
- leetcode491 递增子序列
- ESP-IDF 添加自己的组件
- leetcode 300. 最长递增子序列
- Vant3 +ts packaged simple step advancer component
猜你喜欢

HTTP cache < strong cache and negotiation cache >

Typescript common types (I)

LCD parameter interpretation and calculation

Introduction to service grid and istio - continued

Machine learning series (5): Naive Bayes

Vant3+ts encapsulates uploader upload image component

Schematic diagram of active differential crystal oscillator and differences among lv-pecl, LVDS and HCSL

TypeScript类型声明文件(三)

ES7 does not use parent-child and nested relationships to implement one to many functions

es7不使用父子和嵌套关系来实现一对多功能
随机推荐
USB转串口那些事儿—串口驱动类型
JS sum of two numbers
309. the best time to buy and sell stocks includes the freezing period
Leetcode491 increasing subsequence
在思科模拟器Cisco Packet Tracer实现自反ACL
HTTP缓存<强缓存与协商缓存>
Research results of low code platform
Stack in JS (including leetcode examples) < continuous update ~>
torch.where的新用法(很老但是大家忽略的用法)
JS for Fibonacci sequence
TypeScript高级类型(二)
Summary of interview questions
PHP implementation of infinite classification tree (recursion and Optimization)
First principles of enterprise architecture
JS中的字符串(含leetcode例题)<持续更新~>
VirtualLab基础实验教程-4.单缝衍射
C#的变量
Schéma de cristallisation différentielle active et différence entre LV - PECL, LVDS et hcsl
C business serial number rule generation component
Gospel of audio and video developers, rapid integration of AI dubbing capability