[請益] MSSQL語法轉換MySQL語法一問
這是一個供分頁使用的Ms-SQL Command
ipage = 1 //ipage 是分頁的頁碼
cpage = 5 //cpage 是每頁顯示筆數
select Top "+ipage+" *
from authors
where au_id not in (
select top "+(cpage-1)*ipage+" au_id
from authors
order by au_id desc
)
order by au_id desc
i = 第幾頁(如:2,3,4...)
<a herf="test.jsp?ipage="<%= i %>>
---------下面為自己改寫的Mysql command---------------
select *
from authors
where au_id not in (
select au_num
from authors
order by au_num
limit "+(cpage-1)*ipage+"
)
order by au_num desc
limit ipage
出現的錯誤碼為:
1235-The version of MySQL doesn't support 'LIMIT _IN/ALL/ANY/SOME subQuery'
請教我如何依此邏輯,可以改寫成一個可以控制分頁的MysSQL command <('_')> 感謝
--
◤ ╭● 嫂子 叫我鬍子就好了 _(▁)▁
◤龍▃▄▅▄ 我會很有禮貌的 ( ﹎﹎ )
§ ● ● ╯ = = │
◣ ︶ ◣─ ◢
─ ◥◤) ψmroscar ╰斗╯
◢ | | 三明書局-你所不知道的關二哥 ◥
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.111.166.142
推
12/14 16:05, , 1F
12/14 16:05, 1F
→
12/14 16:06, , 2F
12/14 16:06, 2F
→
12/14 17:05, , 3F
12/14 17:05, 3F
→
12/14 19:11, , 4F
12/14 19:11, 4F
→
12/14 23:13, , 5F
12/14 23:13, 5F
已更改上面SQL 指令 希望能協助改寫成MySQL 謝謝
※ 編輯: victer0327 來自: 122.100.114.222 (12/14 23:20)
推
12/14 23:48, , 6F
12/14 23:48, 6F
假設資料庫中前十筆有值的資料編號為 1,5,6,7,8,9,10,15,16,18...
設 i 起始值為 1 並會接收在最後點選的頁面數而決定接下來的 i 會為多少
設 j 為每頁顯示的資料筆數(假設為5)
請找出 "當頁數為i時,會列出
如: 當i = 1時,頁面會顯示 1,5,6,7,8 ; i = 2時,為 9,10,15,16,18 以此類推...
最後則以<a herf="xx.jsp?i="<%= 第幾頁 %>> 作為下次loading的i值
不知這樣是否清楚^^
※ 編輯: victer0327 來自: 122.100.114.222 (12/15 00:04)
※ 編輯: victer0327 來自: 122.100.114.222 (12/15 00:11)
推
12/15 00:22, , 7F
12/15 00:22, 7F
→
12/15 00:22, , 8F
12/15 00:22, 8F
→
12/15 00:23, , 9F
12/15 00:23, 9F
→
12/15 00:24, , 10F
12/15 00:24, 10F
I See!!! 是我一開始搞錯limit後面該擺的值了,我以為是 limit from,to
感謝感謝@@
※ 編輯: victer0327 來自: 140.111.166.142 (12/15 09:26)