前言

使用SQLyog添加DOUBLE字段报错

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 ') NULL COMMENT '里程数' after `d_id`' at line 2
ALTER TABLE `enterprise_car`.`order` ADD  `o_mileage2` DOUBLE(2) NULL  AFTER `d_id`

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

原因一

SQL有问题
正确SQL格式
之前写只写了10,没有写精度
正确写法

ALTER TABLE `enterprise_car`.`order` ADD COLUMN o_mileage DOUBLE(10,2) COMMENT '里程数'

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

注意SQL格式问题

原因二

关键字问题使用关键字就会 报错,加引号

UPDATE ORDER SET c_id=?, CONDITION=? WHERE (o_id = '2009')

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version_数据库_03


正确写法

UPDATE `order` SET c_id=?, `condition`=? WHERE (o_id = '2009')

原因三

SQL格式是真的有问题

UPDATE `order`  WHERE (o_id = '2009')
UPDATE `order` SET c_id=? WHERE (o_id = '2009')