mysql> select * from newstu;
+------+------+------+
| id | name | age |
+------+------+------+
| 15 | 张三 | 18 |
| 12 | 李四 | 20 |
| 13 | 王五 | 22 |
| 14 | 六六 | 23 |
+------+------+------+
以上是我的table
以下是报错信息
mysql> select top 2 * from newstu;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2 * from newstu' at line 1
mysql 要用 limit 语句
-- 从newstu 表中选择前 2 条记录
select * from newstu limit 2;
不知道你这个问题是否已经解决, 如果还没有解决的话:FIRST() 函数返回指定的字段中第一个记录的值
注意:TOP 是Sql Server 数据库中的,在MySQL使用LIMIT限制条数
-- 左闭右开
SELECT * FROM grade LIMIT 0,5