我試圖插入一個新的記錄到Prestashop SQL數據庫,並且一切工作良好,直到我需要引入日期記錄。無法插入日期到SQL表
如果我嘗試執行這條線,我得到一個錯誤,說:「你在你的SQL語法錯誤」
INSERT INTO ps_specific_price
(id_product, [reduction], [reduction_type]
, [from], [to])
VALUES (100145, 0.15, "percentage"
, "2016-10-10 00:00:00", "2017-10-10 00:00:00")
如果我用的是相同的,但沒有日期,它的工作:
INSERT INTO ps_specific_price
(id_product, [reduction], [reduction_type])
VALUES (100145, 0.15, "percentage")
我正在使用此代碼從VBA與ODBC連接器和MySQL ODBC 5.3 ANSI驅動程序。
我的代碼有什麼問題? 我試過不同的時間格式,有和沒有小時標記...不工作...
謝謝!
這裏是架構:
'id_specific_price' int(10) unsigned NOT NULL AUTO_INCREMENT,
'id_specific_price_rule' int(11) unsigned NOT NULL,
'id_cart' int(11) unsigned NOT NULL,
'id_product' int(10) unsigned NOT NULL,
'id_shop' int(11) unsigned NOT NULL DEFAULT '1',
'id_shop_group' int(11) unsigned NOT NULL,
'id_currency' int(10) unsigned NOT NULL,
'id_country' int(10) unsigned NOT NULL,
'id_group' int(10) unsigned NOT NULL,
'id_customer' int(10) unsigned NOT NULL,
'id_product_attribute' int(10) unsigned NOT NULL,
'price' decimal(20,6) NOT NULL,
'from_quantity' mediumint(8) unsigned NOT NULL,
'reduction' decimal(20,6) NOT NULL,
'reduction_tax' tinyint(1) NOT NULL DEFAULT '1',
'reduction_type' enum('amount','percentage') NOT NULL,
'from' datetime NOT NULL,
'to' datetime NOT NULL,
PRIMARY KEY ('id_specific_price'),
UNIQUE KEY 'id_product_2' ('id_cart','id_product','id_shop','id_shop_group','id_currency','id_country','id_group','id_customer','id_product_attribute','from_quantity','id_specific_price_rule','from','to'),
KEY 'id_product' ('id_product','id_shop','id_currency','id_country','id_group','id_customer','from_quantity','from','to'),
KEY 'from_quantity' ('from_quantity'),
KEY 'id_specific_price_rule' ('id_specific_price_rule'),
KEY 'id_cart' ('id_cart')
你可以顯示'ps_specific_price'的表格模式嗎?如果這是MySQL,你應該這樣標記。 –
這是否工作'INSERT INTO ps_specific_price([from],[to])VALUES('2016-01-01','2016-04-04')'? – surfmuggle
這裏是模式: – user3254924