select * from table1 limit (2-1)*10,10
报错信息
1064 - 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-1)*10,10' at line 1
不可以这么写,limit后面带常量;
1.你可以计算好放到limit后面
2. 或者 使用字符串拼接sql语句,(实际也是先计算)
在通过sql语句创建表时报错,下面是错误信息,
[2020-05-09 13:50:42] Connected
zcw20200509> use zcw20200509
[2020-05-09 13:50:42] completed in 3 ms
zcw20200509> CREATE TABLE 'payment'(
'id' bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
'serial' varchar(200) DEFAULT '',
PRIMARY KEY ('id')
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET =utf8
[2020-05-09 13:50:42] [42000][1064] 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 ''payment'(
[2020-05-09 13:50:42] 'id' bigint(20) NOT NULL AUTO_INCREMENT CO' at line 1
[2020-05-09 13:50:42] [42000][1064] 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 ''payment'(
[2020-05-09 13:50:42] 'id' bigint(20) NOT NULL AUTO_INCREMENT CO' at line 1
zcw20200509> CREATE TABLE 'payment'(
'id' bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
'serial' varchar(200) DEFAULT '',
PRIMARY KEY ('id')
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET =utf8
[2020-05-09 13:52:56] [42000][1064] 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 ''payment'(
[2020-05-09 13:52:56] 'id' bigint(20) NOT NULL AUTO_INCREMENT CO' at line 1
[2020-05-09 13:52:56] [42000][1064] 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 ''payment'(
[2020-05-09 13:52:56] 'id' bigint(20) NOT NULL AUTO_INCREMENT CO' at line 1
问题的报错信息是1064 - 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-1)*10,10' at line 1。
根据参考资料中的相关段落,这个错误通常是由于MySQL语句的语法错误导致的。以下是一些可能的解决方案:
检查SQL语句的语法: 请确保你的SQL语句符合MySQL的语法规范。可能你的语句中存在一些错误,导致MySQL无法正确解析。根据报错信息,你可能在分页查询部分的语句中出现了问题,请检查该部分的语法是否正确。
检查语句中是否存在关键字: 根据参考资料中的段落1,可能是因为创建表的过程中使用了MySQL的关键字,导致出现了错误。请检查你的语句中是否存在这样的关键字,如果有,请修改为其他的词或者使用引号将其包裹起来。
检查语句中的特殊字符: 根据参考资料中的段落2,有时候这个错误是由于语句中的特殊字符没有正确处理引起的。请检查你的语句中是否存在这样的特殊字符,并尝试将其处理或者删除。
检查语句中的逗号和括号: 根据参考资料中的段落4,有时候这个错误是由于逗号或括号的使用不正确导致的。请检查你的语句中的逗号和括号是否正确使用,特别是在创建表或查询语句中。
如果以上方法都没有解决你的问题,可能需要进一步了解你的查询语句和表结构的具体情况才能提供更准确的帮助。