不确定这是否可行......
在MYSQL中给出这些数据:
fnPresentLoading() {
this.loading = this.loadingCtrl.create({
content: 'Please wait...'
});
this.loading.present();
如何返回以这样的模式排序的结果集:
AAA
BBB
BBB
CCC
AAA
CCC
DDD
DDD
答案 0 :(得分:2)
您可以使用变量:
SELECT mycol
FROM (
SELECT mycol,
@rnk := IF(@col = mycol, @rnk + 1,
IF(@col := mycol, 1, 1)) AS grp
FROM mytable
CROSS JOIN (SELECT @rnk := 0, @col := '') AS vars
ORDER BY mycol) AS t
ORDER BY grp, mycol;