我有如下表:MySQL的插入错误#1064
CREATE TABLE `test123`.`orders` (
`o_id` varchar(12) NOT NULL DEFAULT '',
`p_id` varchar(10) NOT NULL DEFAULT '',
`p_qty` int(11) DEFAULT NULL,
`p_price` decimal(15,2) DEFAULT NULL,
`o_price` decimal(15,2) DEFAULT NULL,
`c_charge` decimal(15,2) DEFAULT NULL,
`total_price` decimal(15,2) DEFAULT NULL,
`c_name` varchar(100) NOT NULL DEFAULT '',
`c_address` text NOT NULL,
`c_pin` varchar(11) DEFAULT NULL,
`c_mobile` varchar(11) NOT NULL DEFAULT '',
`c_email` varchar(100) DEFAULT NULL,
`o_dt` date NOT NULL,
`o_delivery_dt` date DEFAULT NULL,
`o_remarks` varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
试图执行以下插入查询:
insert into [orders] ([o_id],[p_id],[p_qty],[p_price],[o_price],[c_charge],[total_price],[c_name],[c_address],[c_pin],[c_mobile],[c_email],[o_dt],[o_delivery_dt],[o_remarks])
values('2016020002','PA001','1','900.00','900.00','','900.00','ABCD','my full address','123456','12345678','[email protected]','2016-02-28 17:04:29','','');
在此插入查询得到错误的执行如“你有一个错误的SQL语法;查看与您的MySQL服务器版本相对应的手册,查看在[o_id],[p_id],[p_qty],[p_price],[o_price],[c_charge],[total_price],[ c_name],[c_a'在第1行] error no:1064.
请帮忙,在这里找不到任何语法错误。
从查询中删除所有'['和']' - 看起来像SQL-Server语法。 mysql中的关键字escape是backtics。 – Kenney
感谢Kenney,你的建议像魅力一样工作......非常感谢...... – SumanRana