以下是带有动态数组的 MySQL LIKE 查询MySQL 限制范围无法显示前 3 行?

mysqlmysqli database

以下是仅显示范围内设置 LIMIT 的前 3 行的语法 −

select *from yourTableName limit yourStartIndex,yourEndIndex;

首先我们创建一个表 −

mysql> create table demo67
−> (
−> id int,
−> user_name varchar(40),
−> user_country_name varchar(20)
−> );
Query OK, 0 rows affected (0.72 sec)

使用 insert 命令向表中插入一些记录 −

mysql> insert into demo67 values(10,'John','US');
Query OK, 1 row affected (0.19 sec)

mysql> insert into demo67 values(1001,'David','AUS');
Query OK, 1 row affected (0.14 sec)

mysql> insert into demo67 values(101,'Mike','UK');
Query OK, 1 row affected (0.09 sec)

mysql> insert into demo67 values(102,'Carol','AUS');
Query OK, 1 row affected (0.11 sec)

mysql> insert into demo67 values(110,'Chris','US');
Query OK, 1 row affected (0.36 sec)

mysql> insert into demo67 values(105,'David','AUS');
Query OK, 1 row affected (0.08 sec)

使用 select 语句显示表中的记录 −

mysql> select *from demo67;

这将产生以下输出 −

+------+-----------+-------------------+
| id   | user_name | user_country_name |
+------+-----------+-------------------+
| 10   | John      | US                |
| 1001 | David     | AUS               |
| 101  | Mike      | UK                |
| 102  | Carol     | AUS               |
| 110  | Chris     | US                |
| 105  | David     | AUS               |
+------+-----------+-------------------+
6 rows in set (0.00 sec)

这是 MySQL 限制显示前三行的查询 −

mysql> select *from demo67 limit 0,3;

这将产生以下输出 −

+------+-----------+-------------------+
| id   | user_name | user_country_name |
+------+-----------+-------------------+
| 10   | John      | US                |
| 1001 | David     | AUS               |
| 101  | Mike      | UK                |
+------+-----------+-------------------+
3 rows in set (0.00 sec)

相关文章