Home >Database >Mysql Tutorial >MySQL查询某个记录行号

MySQL查询某个记录行号

WBOY
WBOYOriginal
2016-06-07 14:57:082219browse

查询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)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn