0

有没有办法用下面的东西对数字进行排序

GameID   Turn   
3         2
6         1
7         2
5         2
8         0
9         1

return should be { for example GameID 6 is TURN for the Game or Left in the Game }
GameID   Turn
6         1
9         1
8         0
3         2
5         2
7         2

another example { for example GameID 7 is TURN for the Game or Left in the Game }
GameID   Turn
7         2
3         2
5         2
8         0
9         1
6         1

那只是我需要弄清楚的一个样本。是否可以对转弯进行排序?

我不能使用 ORDER BY turn DESC/ASC 因为做的顺序就是这样2 1 0,而 ASC 0 1 2bu 我需要弄清楚的是,如果我们2从那时开始,现在以这种方式排序 { 我们有 0 1 2 }排序应该是这样的,2 0 1或者如果我们从第 1 回合开始,排序应该是这样的1 2 0

我希望有什么能明白我的意思...

请我已经用过 asort 但它不适合。还有其他用于排序的php函数吗?

谢谢...

4

2 回答 2

2

您可以尝试ORDER BY FIELD

  SELECT *
    FROM table
ORDER BY FIELD(Turn, 1, 0, 2) ASC
 --                           DESC
于 2012-08-31T11:51:06.873 回答
0
SELECT 
  GameID,Turn
FROM yourtableorview
WHERE yourcriteria
ORDER BY IF(Turn<$startturn,Turn+99999999,Turn)
于 2012-08-31T11:52:06.313 回答