报错[Err] 1064 - You have an error in your SQL syntax;
在写php,写到后面msyqli插入数据,一直报错,复制到Navicat中运行,依然报错。
[Err] 1064 - You have an error in your SQL syntax;难受
insert into order (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')
全是varchar
后来查了,说是用了MySQL的关键字需要加引号,查询网址:https://dev.mysql.com/doc/refman/8.0/en/keywords.html#keywords-8-0-detailed-S
关键字是在SQL中具有重要意义的单词。某些关键字,如SELECT
, DELETE
或 BIGINT
,被保留,需要用作标识符,例如表和列名特殊待遇。内置函数的名称也可能如此。
我的order 就是关键词
insert into 'order' (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')
依然报错[Err] 1064 - You have an error in your SQL syntax;再查发现不是用英文下的单引号,是用英文下的 ` 就是键盘左上角那个
insert into `order` (Oid,user_id,Odate,Onum,Tid,states) values ('1612715211','1612715212','2021-02-01 02:28:02','9','1612715213','2')
受影响的行: 1
时间: 0.058s
真的不容易