0
点赞
收藏
分享

微信扫一扫

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

日月同辉9908 2022-04-13 阅读 158
mysql> SELECT TOP 3 prod_name
    -> FROM products;
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 '3 prod_name

先翻译错误:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versionfor the right syntax to use near '3 prod_name

错误1064(42000):您的sql语法出现错误;请检查与mysql服务器版本对应的手册,以获得使用接近‘3 prod_name的正确语法

解决发现 MySQL 查询前几列语法是:limit

正确写法

mysql> SELECT listName
    -> FROM tableName;
    -> LIMIT 5;

如果你使用MySQL、MariaDB、PostgreSQL或者SQLite,需要使用LIMIT子句,像这样:

mysql> SELECT listName
    -> FROM tableName;
    -> LIMIT 5;

如果你使用Oracle,需要基于ROWNUM(行计数器)来计算行,像这样:

mysql> SELECT listName
    -> FROM tableName;
    -> WHERE ROWNUM <= 5;
举报

相关推荐

0 条评论