mysql fetch previous or next record order by anyother field name and not by using order by id如何下/上一紀錄在MySQL
select * from table where id > $id order by name asc limit 1
select * from table where id < $id order by name desc limit 1
我能夠獲得下一個和以前的記錄,但在這種情況下,我怎樣才能 下一個和以前的記錄更新升級。
ID Links orderID
14 Google.com 1
15 Yahoo.com 2
20 gmail.com 3
25 facebook.com 4
關於什麼的,如果我用+和 - 在前面的按鈕各個環節的升級和降級它們,然後重新排列由單編號菜單命令?
使用您已知的那些查詢來檢索要更新的行的ID,使用您剛剛檢索到的兩個ID發出兩個具有WHERE ID = X'的UPDATE查詢。哪部分是問題? –