当前位置:网站首页>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
}
边栏推荐
- 有源差分晶振原理圖以及LV-PECL、LVDS、HCSL區別
- Gd32f4xx controls dgus variable display
- Gd32f4xx communicates with electric energy meter conforming to dlt645_ two
- String s = null ; String s = new String(); String s = "; what is the difference between string s?
- High speed layout guidelines incomplete
- Lightweight and convenient small program to app technology solution to realize interconnection with wechat / traffic app
- es7不使用父子和嵌套关系来实现一对多功能
- VirtualLab basic experiment tutorial -6 Blazed grating
- VirtualLab basic experiment tutorial -4 Single slit diffraction
- Esp-idf adds its own components
猜你喜欢

Explanation of core interrupt of Godson processor

Machine learning series (5): Naive Bayes

When openharmony meets openeuler

USB to serial port - maximum peak serial port baud rate vs maximum continuous communication baud rate

Introduction to reinforcement learning and analysis of classic items 1.3

High-Speed Layout Guidelines 未完...

Typescript common types (I)
![Interior design style type, rendering 100 invitation code [1a12]](/img/90/8bbfbe33c5b412498744c0ea0ed559.jpg)
Interior design style type, rendering 100 invitation code [1a12]

Nixos 22.05 installation process record

C语言练习(4)——大数乘除
随机推荐
01-复杂度
leetcode 647. Palindrome substring
js求斐波那契数列
HTTP缓存<强缓存与协商缓存>
Click the list page of vant3+ts+pinia tab to enter the details. The tab on the details page is highlighted in the original position, and the refresh highlight is in the first item by default
Gossip about the source code of redis 89
This shift, I still have to go
迄今微软不同时期发布的SQL Server各版本之间的大致区别,供参考查阅
Stream流注意点
Error record: illegalstateexception: optional int parameter 'XXXX' is
Lenovo responded that there are too many and too messy notebooks: it is now the product adjustment period and will be divided into three series of digital /air/ pro in the future
Gospel of audio and video developers, rapid integration of AI dubbing capability
leetcode 674 最长递增子串
深圳3月14日起全市停工停业7天居家办公心得|社区征文
C language practice (4) -- multiplication and division of large numbers
VirtualLab basic experiment tutorial -6 Blazed grating
Window版本pytorch入门深度学习环境安装与配置
MIPS general purpose register + instruction
01 complexity
Is it safe to open an account in flush