执行此查询时出现此错误:
SQLSTATE[HY000]: General error: 1366 Incorrect decimal value: '' for column 'taxes' at row 1 (SQL: insert into `delivery_note_elements` (`delivery_note_id`, `name`, `quantity`, `unit`, `taxes`, `discount`, `total`, `updated_at`, `created_at`) values (1344, x, 1, 1, , , 1, 2016-08-05 10:57:12, 2016-08-05 10:57:12))
我读过有关 STRICT_TRANS_TABLES mysql 模式的内容,但我已禁用它,重新启动 MySQL 并且错误仍然存在。
mysql -u root -p -e "select @@sql_mode"
+------------+
| @@sql_mode |
+------------+
| |
+------------+
有什么想法吗?
谢谢!
最佳答案
这似乎是你的 SQL
INSERT INTO `delivery_note_elements` (
`delivery_note_id`,
`name`,
`quantity`,
`unit`,
`taxes`,
`discount`,
`total`,
`updated_at`,
`created_at`
)
VALUES (
1344, # delivery_note_id
x, # name
1, # quantity
1, # unit
, # taxes <---- no value here
, # discount <---- no value here
1, # total
2016-08-05 10:57:12, # updated_at
2016-08-05 10:57:12 # created_at
)
该错误表明您的taxes
值错误。税收是你的第五个值(value)。看看值(value)观。有两个直接按顺序的逗号,该位置之间没有值。那是你的错误。您的表架构 (CREATE TABLE
) 似乎不允许此处使用 NULL
值。
关于php - MySQL默认值不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38787650/