看板 Database 關於我們 聯絡資訊
※ 引述《victer0327 (victory)》之銘言: : 這是一個供分頁使用的Ms-SQL Command : ipage = 1 //ipage 是分頁的頁碼 : cpage = 5 //cpage 是每頁顯示筆數 : select Top "+ipage+" au_id,au_lname,au_fname,address,phone : 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 : ---------下面為自己改寫的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 <('_')> 感謝 mssql 因為沒有mysql 中好用的 limit, 所以mssql必須將 table 改寫成 top+map 的方式達成mysql分頁效果。 如果您只是要單純使用mysql來做分頁 只要單純 select * from `authors` where `au_id` ......(加入您要的sql條件) order by XXXXXX (加入您要的排序.... 非必要) limit 分頁計算筆數 , 單頁顯示筆數 舉個例子 select * from `authors` where `au_id` != '10' limit $pages,50 (一頁顯示50筆 可自行設計) $pages = (當下的頁面-1)*頁顯示筆數。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.31.193.1