I'm trying to insert a new record into a Prestashop SQL database and all works well till I need to introduce date records.
If I try to execute this line, I get an error saying "You have an error in your SQL syntax"
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")
If I use the same but without the date, it's working:
INSERT INTO ps_specific_price
(id_product, [reduction], [reduction_type])
VALUES (100145, 0.15, "percentage")
I'm using this code from VBA with an ODBC connector and MySQL ODBC 5.3 ANSI Driver.
What is wrong with my code? I've tried different time formats, with and without hour stamp... not working...
Thanks!
Here is the schema:
'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')