我有下表:-
id | name
1 | abc
5 | def
9 | ghi
10 | jkl
11 | mno
12 | pqr
我想获取给定id的索引
例子:-
SELECT `id`, INDEX FROM `table` WHERE `id`>5
// INDEX is the function that I want
结果:-
id | INDEX
9 | 3
10 | 4
11 | 5
12 | 6
我在谷歌上搜索了一下,没有找到答案。
在此先感谢您的帮助。
最佳答案
SELECT id
,(select count(1) from table
where id<9) FROM table
WHERE id
=9;
关于mysql - 获取mysql结果raw的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47940160/