https://static.06ms.com/static/images/index/4.jpg

MySQL查询某个记录行号

mysql> select count(*)  from test  where id <= (select id from test  where id=16); 
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)
mysql> select count(*)  from test  where id <= 16;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)