我出于某种原因出现了这个错误,我在MySQL上测试了它并且工作正常,但我不确定为什么它不能用于SQLite,错误是
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: ":")
每当我尝试使用
时select * from (SELECT `ID`, `Level`, `Experience`, (@rn := @rn + 1) as `rank` FROM `userranking` cross join (select @rn := 0) const ORDER BY `Level` DESC, `Experience` DESC ) `userranking`
编辑:
所以我试图先对这张表进行排序,
+----------------+
| ID Exp Level |
+----------------+
| 1 41 3 |
| 2 1 1 |
| 3 31 4 |
| 4 43 3 |
| 5 101 8 |
+----------------+
然后在同一个查询中对它进行排序后,我希望得到不在表中的rank
,因此它应该创建该用户的临时值。所以看起来应该是这样的
+----------------------+
| rank ID Exp Level |
+----------------------+
| 1 5 101 8 |
| 2 3 31 4 |
| 3 4 43 3 |
| 4 1 41 3 |
| 5 2 1 1 |
+----------------------+