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

MySQL查询某个记录行号

WBOY
Release: 2016-06-07 14:57:08
Original
2200 people have browsed it

查询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)
Copy after login
mysql> select count(*)  from test  where id <= 16;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)

Copy after login
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template