首页 >数据库 >mysql教程 >MySQL查询某个记录行号

MySQL查询某个记录行号

WBOY
WBOY原创
2016-06-07 14:57:082219浏览

查询test表中id为16的记录是第几行的两个方法 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 wher

查询test表中id为16的记录是第几行的两个方法 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)

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn