1. 程式人生 > 其它 >mysql複習筆記

mysql複習筆記

從單表查詢到多表查詢

1 sql/db/dbms 他們都是什麼,它們之間的關係又是怎麼樣?

DB: 資料庫,以一個檔案的形式儲存到硬盤裡

DBMS: 資料庫管理系統 (...)

SQL: 結構化查詢語言,是一門標準通用的語言。

sql屬於高階語言,sql的編譯是看不見的,sql語句是由DBMS完成編譯的。

DBMS -》 (執行者)

SQL -》 (操作者)

DB


2 什麼是表?

表: table
表:table時資料庫的基本組成單元,所有的資料都以表格的形式組織,目的:可讀性強。

一個表包含: 行和列:
行: 資料(data)
列: 欄位(cloumn)

學號 姓名 年齡
·····················
110 20 20
120 30 30

bigint - 對應java中的long型別


每一個欄位應該包括哪一些屬性?

欄位名,資料型別,相關的約束(比如說為空/不為空的限制條件)。



3.sql語句怎麼分類呢?

DQL(資料查詢語言) :查詢語句 select

DML(資料操作語言): insert delete update ,對錶裡面的資料進行增刪改查

DDL(資料定義語言): create drop alter ,針對的時表結構,不是資料

TCL(事務控制語言): commit (程式設計師兩大難,一執行緒,二事務)

DCL(資料控制語言): grant授權


4.匯入資料(後期大家練習使用)

第一步: mysql登入 mysql -uroot -p444

第二步: mysql檢視有哪些資料庫

show databases; (不是sql語句,這是mysql的命令)

第三步: 建立自己的資料庫,iot
create database iot; (不是sql語句,這是mysql的命令)

第四步: 選擇自己想使用的資料庫:
use iot;

第五步: 看一看當前我們建立的這個iot資料庫裡面的表
show tables;

第六步: 匯入我們自己的練習資料:
source iot.sql (不加分號)



5 iot.sql 這個檔案以sql結尾,這樣的被稱為“sql指令碼檔案”
當一個檔案的副檔名是.sql,並且該檔案中編寫了sql語句,這樣的檔案就是sql指令碼。

source : 直接用這個命令,即可匯入sql指令碼檔案
錯誤: ERROR 1046 (3D000): No database selected

6. drop database iot;

7. 資料匯入完成,我們來檢視一下表結構:

desc user;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| uid | int(6) | NO | PRI | NULL | auto_increment |
| uName | varchar(100) | YES | | NULL | |
| uSex | varchar(100) | YES | | NULL | |
| uAddress | varchar(255) | YES | | NULL | |
| uPhone | varchar(255) | YES | | NULL | |
| uHeight | double(20,2) | YES | | NULL | |
| cName | varchar(255) | YES | | NULL | |
+----------+--------------+------+-----+---------+----------------+
主鍵: 關係型資料庫中的一條記錄中有若干個屬性,若其中某一個屬性組(注意是組)能唯一標識一條記錄,該屬性組就可以成為一個主鍵
假如,有一個學生表,(學號,性別,班級,年齡),其中每個學生的學號是唯一的,不能重複,學號==主鍵。
主鍵是確定一條記錄的唯一標識,比如:身份證,學號....等等

8. 常用的命令:

select database(); 檢視當前在操作哪一個資料庫

\c : 退出命令,命令不執行。

show create table user;

9. 表資料查詢

DQL : 簡單查詢

語法格式: select 欄位名1,欄位名2,.... from 表名;

提示:
1.任何一條sql語句必須;結尾
2. sql語句不分大小寫的
3.關鍵字不能亂寫
4.如果第一次安裝好查詢出現中文繁體亂碼,要一條語句進行修改
show variables like '%char%'; (檢視當前的編碼方式)
set character_set_results=gb2312; (如果亂碼請改這個)
5. 查出來橫向顯示(尾部+\G即可,\G實際上已經帶了分號)

參與數學運算的查詢:
select uName,uHeight*100 from user\G

增加欄位別名:
select uName as 'name' , uHeight*100 as 'height' from user\G

10. 條件查詢:

語法格式: select 欄位名1,欄位名2,.... from 表名 where 條件;

比如說:我們要查詢指定身高的同學資料:
select * from user where uHeight = '178.91';

+-----+--------+------+--------------+-------------+---------+--------------+
| uid | uName | uSex | uAddress | uPhone | uHeight | cName |
+-----+--------+------+--------------+-------------+---------+--------------+
| 3 | 姜沸沸 | 男 | 湖南省長沙市 | 18855474458 | 178.91 | 物聯網1902班 |
+-----+--------+------+--------------+-------------+---------+--------------+
1 row in set (0.00 sec)


比如說:我們想知道身高在175以上的同學是哪些?
select * from user where uHeight > '175.00';

比如說:我們想知道身高在160-180的同學是哪些?
select * from user where uHeight > '160.00' and uHeight < '180.00';

and和or 是兄弟 , and就是兩個都要滿足 ,or 就是隻用滿足一個

select * from user where uHeight > '160.00' and uHeight < '180.00'; (既要大於160,也要小於180)
select * from user where uHeight > '160.00' or uHeight < '180.00'; (大於160可以,或者小於180也可以)

in 包含 (相當於多個or)
比如說:我們想知道身高是176.40,178.91,174.60這幾個之中的的同學是哪些?
select * from user where uHeight not in ('176.40','178.91','174.60');

表示式的優先級別:
查詢身高大於170的並且班級是物聯網1901或者1902的同學;
select * from user where uHeight > '170.00' and (cName = '1901' or cName = '1902');

navicat: 資料庫系統管理軟體
https://www.navicat.com.cn/manual/online_manual/cn/navicat/win_manual/index.html#/installation

1. between ... and ... (在數值方面的比較上,是閉區間,15-20,如果它用在字元的比較上,是左閉右開)
select uName,uSex,uAddress,uHeight,cName from user where uHeight > '160.00' and uHeight < '180.00';
select uName,uSex,uAddress,uHeight,cName from user where uHeight BETWEEN '160.00' and '180.00';


2. <> != not in :
例如我要查詢班級不為1901的學生資料:
select uName,uSex,uAddress,uHeight,cName from user where cName <> '1901';
select uName,uSex,uAddress,uHeight,cName from user where cName != '1901';
select uName,uSex,uAddress,uHeight,cName from user where cName not in ('1901');

3. null (null它不是一個值,為空,但是不是空值,它不能用等號來衡量,用is null來進行區別,把null跟''空字串區分開)
找出沒有填寫性別的同學資料:
select uName,uSex,uAddress,uHeight,cName from user where uSex is null; (只是把null的資料查了出來)

select uName,uSex,uAddress,uHeight,cName from user where uSex is null or uSex =''; (正確)

select uName,uSex,uAddress,uHeight,cName from user where uSex in('','null'); (錯誤的)

1. 查詢班級為1901班的男生資料
select uName,uSex,uAddress,uHeight,cName from user where cName = '1901' and uSex = '男';

2. 查詢身高在170-180之間的男生資料
select uName,uSex from user where uHeight between '170.00' and '180.00';

3. 查詢性別為空的學生資料(性別未填寫的)
select uName,uSex,uHeight from user where uSex in null or uSex = '';

4. 查詢班級為1901的或者性別為男的學生資料
select uName,uSex,uHeight,cName from user where cName = '1901' or uSex = '男';

5. 查詢身在湖南省永州市或者是湖南省長沙市的學生資料(用兩種方法)
select uName,uSex,uAddress,uHeight,cName from user where uAddress = '湖南省永州市' or uAddress = '湖南省長沙市';
in:
select uName,uSex,uAddress,uHeight,cName from user where uAddress in('湖南省永州市','湖南省長沙市');



11. like(模糊查詢):
在模糊查詢中,掌握兩個關鍵點即可:一個是 % , 一個是 _
%: 任意個 字元 , _ : 一個字元

找出衡陽市的學生資料:
select uName,uSex,uAddress,uHeight,cName from user where uAddress = '湖南省衡陽市'

select uName,uSex,uAddress,uHeight,cName from user where uAddress like '%衡陽%';

找出名字中第二個字是'飛'的同學資料:
select uName,uSex,uAddress,uHeight,cName from user where uName like '_飛%';

找出名字中帶'桑'字的同學資料:
select uName,uSex,uAddress,uHeight,cName from user where uName like '%桑%';

找出名字中帶有 '_' 的同學資料:
select uName,uSex,uAddress,uHeight,cName from user where uName like '%\_%';
轉義: \_

找出名字中最後一個字是'桑'的:
select uName,uSex from user where uName like '%桑';

1). IFNULL : 這個函式用於判斷第一個表示式是否為NULL,如果為NULL,則返回第二個引數的值。
函式格式:
IFNULL(expression,value);

select IFNULL(NULL,'hello'); --> hello

select IFNULL('cash','hello'); --> cash

2). CONCAT() : 將多個字串連線成一個字串 , 是最重要的函式之一
函式格式:
CONCAT(str1,str2,...)

但是,用這個函式要注意,如果中間有任意一個字串為NULL,那麼返回值直接是NULL

select uName,uSex,uAddress,uHeight,cName from user where CONCAT(IFNULL(uName,''),IFNULL(uSex,''),IFNULL(uAddress,''),IFNULL(uPhone,''),IFNULL(cName,'')) like '%1903%';


12.綜合運用:

定義變數:
1. set @變數名 = 值
2. select @變數名 := 值

假設:我想新增一個變數

set @strTest1 = '長沙';
select @strTest1 := '長沙';
select @strTest1;


1). uid在1-6之間並且身在長沙市的同學資料:
select uName,uSex,uAddress,uHeight,cName from user where uid between 1 and 6 and uAddress like '%長沙%';
set @strTest1 = '長沙';
select uName,uSex,uAddress,uHeight,cName from user where uid between 1 and 6 and uAddress like CONCAT('%',@strTest1,'%');


2). 查詢1901班或者1902班並且身高在170以上的男同學:
select @strTest1 := '1901'; select @strTest2 := '1902'; select @strTest3 := '170'; select @strTest4 := '男';
select uName,uSex,uAddress,uHeight,cName from user where cName in (@strTest1,@strTest2) and uHeight > @strTest3 and uSex = @strTest4;

3). 查詢1903班中姓王的女生:
select uName,uSex,uAddress,uHeight,cName from user where cName = '1903' and uSex = '女' and uName like '王%';

4).查詢1903班或者1902班中,姓王並且身高在160-180之間的女生:
select uName,uSex,uAddress,uHeight,cName from user where
uName like '王%' and (cName ='1903' or cName = '1902' ) and uHeight between '160.00' and '180.00' and uSex = '女';

5).模擬搜尋有效使用者資料(輸入性別或者名字或者班級都可以,同學資訊中為NULL 的過濾掉,不顯示)
select uName,uSex,uAddress,uHeight,cName from user where CONCAT(uSex,uName,cName) like '%女%';


13.資料排序:
升序/降序 : order by
1. 按照身高升序來查詢學生資料: (order by 預設升序,在後面指定DESC 降序 ASC升序)
select uName,uSex,uAddress,uHeight,cName from user order by uHeight; # (預設升序-從小到大)

2. 按照身高升序來查詢學生資料,當身高相同的時候,再按照班級來升序排列
select uName,uSex,uAddress,uHeight,cName from user order by uHeight ASC , cName ASC;
原理:越靠前的欄位起到的主導作用就越大,後面的壓根可能會用不上。

3. 找出1901班的同學,並且要求按照身高降序排列:
select uName,uSex,uAddress,uHeight,cName from user where cName = '1901' order by uHeight DESC;
執行原理: order by 是最後執行的,先查,再排序輸出。


14. 分組函式: (也叫聚合函式 ,統計函式,組函式,多行處理函式)

count : 計數的
sum : 求和
avg : 平均值
max : 最大值
min : 最小值


特點:1. 所有的分組函式都是對“某一組”資料進行操作的。
2. sum() , avg() 一般用於處理值
3. max() , min() , count() 可以處理任何型別
4. 分組函式都會自動過濾NULL

1. 找出身高的總和:(sum)
select sum(uHeight) 總身高 from user;

2. 找出最高的身高: (max)
select max(uHeight) 總身高 from user;

3. 找出最低身高: (min)
select min(uHeight) 總身高 from user;

4.找出平均身高: (avg)
select avg(uHeight) 平均身高 from user;

5.查詢使用者表的總人數: count
select count(uName) 平均身高 from user;
select count(*) 平均身高 from user;
select count(uHeight) 平均身高 from user;

2. count(*) 和 count(欄位名) 有什麼區別?
count(*):不是統計某個欄位中的資料,而是統計總記錄數。(和某個欄位是無關的)
count(欄位名): 表示統計欄位中不為NULL的資料總數量。

分組函式也能合起來用:
select count(uSex),avg(uHeight) from user;

單行處理函式:
輸入一行,輸出一行:跟計算有關的查詢

3. 找出身高 高於 平均身高 的同學:
select avg(uHeight) from user;

select * from user where uHeight > avg(uHeight);
[Err] 1111 - Invalid use of group function 無效的使用了分組函式

原因:SQL語句的規則: 分組函式不可直接使用在where子句當中,why?
1). 找出身高高於平均身高的同學資料:
找出平均身高:
select avg(uHeight) from user;
找出高於平均身高的:
select * from user where uHeight > 173.65;
select * from user where uHeight > avg(uHeight);

select * from user where uHeight > (select avg(uHeight) from user); # 正確的
----
因為 group by 是在where 之後才會執行:

select 5
...
from 1
...
where 2
...
group by 3
...
having 4
...
order by 6
...
----

4. group by 和 having
group by : 按照某個欄位或者某些欄位進行分組
having: 對分組之後的資料再次過濾

1). 找出每個班的最高身高
先查有多少班級?
select cName from user group by cName;
這樣寫事先分組,然後再求每個組的身高的最大值,分組函式是在group by 結束以後再執行
select max(uHeight),cName from user group by cName;

注意: 分組函式一般都會和group by 聯合使用,這也是他為什麼被稱為分組函式的原因

並且任何一個分組函式(count sum max min ) 都是在group by 語句執行結束以後才會執行。
當一條sql語句沒有用group by 的時候,整張表的資料會自成一組。

select max(uHeight),cName from user group by cName;


select uName,max(uHeight),cName from user group by cName;
以上在mysql中可以查出來,但是沒有意義,在oracle中會報錯,直接語法錯誤。
所以,記住一個規則:當一條語句中有group by 的時候,select後面只能跟分組函式和參與分組的欄位。

2). 查詢每個班的平均身高
select avg(uHeight),cName from user group by cName;

多個欄位能不能聯合起來一塊分組? 可以用
案例: 找出 每個班 不同性別 的 最高身高:
select
cName,uSex,max(uHeight)
from
user
group by
cName,uSex;

3). having
找出 每個班 的最高身高,要求顯示身高大於175的資料:

第一步:找出每個班的最高身高:
select max(uHeight),cName from user group by cName;

第二步:過濾:>175
where: 效率高,能使用它儘量用它,因為where先執行,所以參加分組的資料就會減少
select max(uHeight),cName from user where uHeight > '175' group by cName ;
having: 效率就低了
select max(uHeight),cName from user group by cName having max(uHeight) > '175';

找出每個班的平均身高,要求顯示身高大於171的資料
第一步:找平均身高
select avg(uHeight),cName from user group by cName;

第二步:過濾 >171
select avg(uHeight),cName from user where avg(uHeight) > '171 group by cName;

select avg(uHeight),cName from user group by cName having avg(uHeight) > '171'; (正確的)

注意:有的情況沒有辦法,只能用having進行過濾

簡單的單表查詢,到此結束,接下來就到了mysql的重點:多表查詢

5. distinct : 查詢結果集去除重複值。
select cName from user;
案例:
select distinct cName from user;

select uName,uSex, distinct cName from user; (錯誤的)
記住: distinct 只能出現在所有欄位的最前面
select distinct cName,uSex from user;

案例:
統計班級的數量:
select count(distinct cName) from user;

15. 連線查詢:
15.1 什麼是連線查詢?
在實際的開發過程中,大部分的情況下都不是從一張表中查詢資料,一般都是多張表聯合查詢,取出最終的結果。

所有欄位都設計在一張表中,會造成資料冗餘,浪費硬碟空間

15.2 連線查詢的分類:
根據語法出現的年代進行劃分:
SQL92(一些老的DBA啊,還在用這類語法)
SQL99(比較新的語法)

根據表的連線方式來劃分:
內連線:
等值連線
非等值連線
自連線

外連線:
左外連線
右外連線

全連線: (很少用)

15.3 在表的連線查詢方面有一種現象:笛卡爾積現象(笛卡爾乘積現象)

案例: 找出每一個學生所在班級的總人數,要求顯示學生姓名和班級總人數。
select uName,cNum from user,class; why? 為什麼是24條資料,因為沒加條件

笛卡爾積現象: 當兩張表在連線查詢的時候,沒有任何條件限制,最終的查詢結果是兩張表記錄條數的乘積

關於表的別名:
select u.uName,c.cNum from user u,class c;
表的別名有什麼好處?
1. 執行效率高。
2. 可讀性強。


15.4 怎麼來避免笛卡爾乘積現象?
當然是增加條件過濾。

案例:找出每一個學生所在班級的總人數,要求顯示學生姓名和班級總人數。

思考:我們多表查詢要加條件,其實就是看多表中哪些欄位相對應

select u.uName,c.cNum from user u,class c where u.cName = c.cName;
(SQL92 語法,目前不贊同這種做法)

15.5 內連線之等值連線 : 最大的特點就是: 條件是等量關係

案例:找出每一個學生所在班級的總人數,要求顯示學生姓名和班級總人數。

select u.uName,c.cNum from user u,class c where u.cName = c.cName;
(SQL92 語法,目前不贊同這種做法)
select b.id ,count(y.*) from bing join yuyue on b.id = y.pid
SQL99 語法:
select u.uName,c.cNum from user u inner join class c on u.cName = c.cName;
SQL99明顯更復雜,但是我們為什麼要用它?
1. 官方推薦,沒有辦法你得用它。
2. 因為sql99語法解結構更清晰,表的連線條件和後來的where條件分離了。

語法總結:
....
A
join
B
on
連線條件
where
...

15.6 內連線之非等值連線: 最大的一個特點就是: 連線條件中的關係是非等量關係。

案例: 找出每個同學的身高所屬區間號,要求顯示學生姓名,身高,身高所屬的區間號

第一步:
select uName,uHeight from user;
select hid from height;
第二步:
select u.uName,u.uHeight,h.hid from user u join height h on u.uHeight BETWEEN h.hMin and h.hMax;

15.7 自連線: 最大的特點: 一張表當兩張表來看,自己連線自己

案例: 找出每個同學的同桌,要求顯示學生姓名和對應的同桌姓名:

第一步:
1. 學生表:select uid,uName,uLeaderId from user;
2. 同桌表:select uid,uName from user;

同學的同桌編號uLeaderId = 這個同桌的uid

select a.uName '學生姓名' ,b.uName '同桌姓名' from user a inner join user b on a.uLeaderId = b.uid;


15.8 外連線:
什麼是外連線?跟內連線有什麼區別?

內連線: 假設A和B兩張表進行連線,使用內連線的話,凡是A表和B表能匹配上的記錄查出來,這就是內連線。
AB兩張表之間沒有主副之分,兩張表是平等的。

外連線: 假設AB兩張表進行外連線,AB兩張表中有一張是主表,一張是副表,主要查詢主表中的資料,
當副表中的資料沒有和主表中的資料匹配上,副表會自動模擬出NULL與之匹配。

外連線的分類:
左外連線(左連線):表示左邊的這張表是主表。
右外連線(右連結):表示右邊的這張表是主表。

左連線有右連線的寫法,右連線也會有對應左連線的寫法。

案例: 找出每個同學的同桌,要求顯示學生姓名和對應的同桌姓名(所有同學的資料都要有):

1. 內連線:
select a.uName as '學生姓名' , b.uName as '同桌姓名' from user a inner join user b
on a.uLeaderId = b.uid;

2. 外連線:因為有主次之分,主表激素按匹配不上次表,資料也會查出來

左外連線:outer不寫也沒關係

select a.uName as '學生姓名' , b.uName as '同桌姓名' from user a left join user b
on a.uLeaderId = b.uid;

右外連線:
select a.uName as '學生姓名' , b.uName as '同桌姓名' from user b right join user a
on a.uLeaderId = b.uid;

外連線:最重要的特點是:主表的資料無條件的全部查詢出來。

案例: 找出哪個班級沒有學生。
select c.*,u.* from user u right join class c on u.cName = c.cName where u.uid is null;


16. 三張表怎麼連線查詢?
案例: 找出每一個同學的班級總人數 以及 身高所屬區間號

格式:
...
A
join B
on
join C
on ...
--------------
select u.uName , c.cNum , h.hid
from user u
join class c
on u.cName = c.cName
join height h
on u.uHeight BETWEEN h.hMin and h.hMax;

案例:找出每一個同學的班級總人數以及身高所屬區間號以及同桌姓名

select u.uName '學生姓名', c.cNum , h.hid , u1.uName '同桌姓名'
from user u
join class c
on u.cName = c.cName
join height h
on u.uHeight BETWEEN h.hMin and h.hMax
left join user u1
on u.uLeaderId = u1.uid;

17. 子查詢:
什麼是子查詢?它可以出現在哪裡?
select語句當中巢狀select語句,被巢狀的select語句就是子查詢。
語法格式:
select ...(select)...
from ...(select)...
where ...(select)...


17.1 where 子句中的子查詢
案例: 找出高於平均身高的學生資訊。
select * from user where uHeight > avg(uHeight); // 錯誤的

第一步:找出平均身高
select avg(uHeight) from user;

第二步:
where 過濾:
select * from user where uHeight > 173.65;

第三步:
select * from user where uHeight > (select avg(uHeight) from user);

17.2 from 後面巢狀子查詢:
案例:找出每一個班級平均身高 的 所屬區間號:
第一步:
找出每個班的平均身高(按照班級分組,求uHeight的平均值)
select cName , avg(uHeight) as avgHeight from user group by cName;

第二步:
將以上的查詢結果當作臨時表t,讓t表和height表相連線
select t.* , h.hid
from (select cName , avg(uHeight) as avgHeight from user group by cName) t
join height h
on t.avgHeight between h.hMin and h.hMax;

案例: 找出每個班級平均的 身高所屬區間號。
第一步:
找出每個同學的身高所屬區間號:
select u.uName,u.uHeight,u.cName,h.hid from user u
join height h on u.uHeight BETWEEN h.hMin and h.hMax;

第二步:
基於以上結果,繼續按照班級分組,求uHeight的平均值
select
u.cName,avg(h.hid)
from user u
join height h
on u.uHeight BETWEEN h.hMin and h.hMax
group by
u.cName;

17.3 select 後面巢狀子查詢:
案例: 找出每個學生所在班級的總人數,要求顯示學生姓名和班級總人數:
連線查詢:
select u.uName,c.cNum from user u join class c on u.cName=c.cName;
子查詢:
select u.uName,(select c.cNum from class c where u.cName=c.cName) from user u;

18. union (可以將查詢結果集相加)
案例:找出班級是1901或1902的學生姓名
第一種: or
select uName,cName from user where cName='1901' or cName='1902';
第二種: in
select uName,cName from user where cName in('1901','1902');
第三種: union
select uName from user where cName = '1901'
union
select uName from user where cName = '1902';

select uName from user
union
select cNum from class;
1列對1列,不然報錯!


19. limit (重點,以後用於分頁查詢)

19.1 limit 是mysql特有的,其他資料庫中沒有,不通用的 (oracle 中有一個相同的機制,叫做rownum)

19.2 limit取結果集中的部分資料,這就是它的作用

19.3 語法規則:
limit startIndex length
startIndex表示起始位置,從0開始,0表示第一條資料,可以不寫,不寫的時候預設為0
length表示取幾個

案例: 取出身高前3名的學生資料(降序排序,再取3個)
第一步:
select uName,uHeight from user order by uHeight desc;
第二步:取前三條資料
select uName,uHeight from user order by uHeight desc limit 0,3;
select uName,uHeight from user order by uHeight desc limit 3;

19.4 limit是sql語句最後執行的一個環節
select ... 5
from ... 1
where ... 2
group by ... 3
having ... 4
order by ... 6
limit ... 7

案例: 取出身高排名在第3到第6的學生資料(降序再取)
select uName,uHeight from user order by uHeight desc limit 2,4;


通用的標準分頁sql?

每頁顯示8條記錄:(limit 0,3)
第 1 頁: 0,8
第 2 頁: 8,8
第 3 頁: 16,8
第 4 頁: 24,8
......

每頁顯示 pageSize 條記錄:
第 pageNo 頁 : ?,pageSize

(pageNo -1)*pageSize , pageSize

java程式碼:
{
int pageNo = 2; //頁碼是2
int pageSize = 10; //每頁顯示10條記錄

limit (pageNo -1)*pageSize , pageSize // 10,10
}



本文來自部落格園,作者:沒有煩惱的貓貓,轉載請註明原文連結:https://www.cnblogs.com/maomao777/p/15927054.html