如何按重复顺序排序行?

时间:2017-05-05 18:42:51

标签: mysql sorting unique sequence

我有一张这样的表:

+----+--------+--------------------+
|  1 | Apple  | Message 1          |
|  2 | Orange | Message two        |
|  3 | Lime   | Some data          |
|  4 | Banana | More data          |
|  5 | Lime   | Boom. This is data |
|  6 | Pear   | I'm on 6 row       |
|  7 | Orange | Foo and Bar here   |
|  8 | Banana | Remember Baz       |
|  9 | Apple  | Big fat juicy data |
| 10 | Lime   | More values here   |
| 11 | Pear   | I'm almost empty   |
+-------------+--------------------+

我有一些序列,比如:

(Banana, Apple, Orange, Lime, Pear)

所以我需要这样排序:

+----+--------+--------------------+
|  4 | Banana | More data          |
|  1 | Apple  | Message 1          |
|  2 | Orange | Message two        |
|  3 | Lime   | Some data          |
|  6 | Pear   | I'm on 6 row       |
|  8 | Banana | Remember Baz       |
|  9 | Apple  | Big fat juicy data |
|  7 | Orange | Foo and Bar here   |
|  5 | Lime   | Boom. This is data |
| 11 | Pear   | I'm almost empty   |
| 10 | Lime   | More values here   |
+-------------+--------------------+

我怎么能这样排序并且还有分页?

或者,通常,我需要对行进行排序,以便结果集中的每N行都是唯一的。

如何?

0 个答案:

没有答案
相关问题