看板 Database 關於我們 聯絡資訊
不知道你的要求是不是要找出最新的兩筆資料之後再對index作asc排序 我先想到的方式是 select a.* from ( select * from `test` order by index desc limit 2) a order by a.index asc 不過好像mysql 5.0.45不能用這寫法, 可能是我寫錯,就換另一種寫法 SELECT b.* FROM `test` b RIGHT JOIN (SELECT `index` FROM `test` ORDER BY `index` DESC LIMIT 2)a on a.`index` = b.`index` Order By b.`index` ASC 顯示結果如下 顯示完整文字 index name 編輯 刪除 3 阿貓 編輯 刪除 4 阿狗 如有錯誤請指教 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.250.32.15
chweng:沒錯!這就是我要的結果,非常感謝^^ 03/06 17:32