Re: [SQL ] MySQL 的 Limit 用法
※ 引述《peter1 (killer bee)》之銘言:
: 有在板上爬了一些文
: 但實用上卻發現會錯誤
: 想再來問一下Limit的用法
: 現在是想要從資料庫中照A條件撈最新100筆
: 再讓這100筆照B條件去排序
: 所以是否應該這樣子寫
: Select * From (Select * From table order by A Limit 100) order by B
: 這樣子寫可以嗎?
: 請指正 感謝:)
Mysql 的版本要注意一下,早期版本不支援子查詢,細節我忘了
應該是這樣下就可以了
select * from (select * from table order by a limit 100 ) as newtable
order by newtable.b
可以參考error(#1248 Every derived table must have its own alias)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.126.63.16
※ 編輯: arrack 來自: 59.126.63.16 (06/25 13:19)
推
06/25 23:57, , 1F
06/25 23:57, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):