2016-11-22 4 views
0

新しいレコードをPrestashop 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") 

を「あなたはあなたのSQL構文でエラーが発生している」というエラーが出ます:

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') 
+1

'ps_specific_price'のテーブルスキーマを表示できますか?これがMySQLの場合は、そのようにタグ付けする必要があります。 –

+0

これはINSERT INTO ps_specific_price([from]、[to])VALUES( '2016-01-01'、 '2016-04-04') 'で動作しますか? – surfmuggle

+0

ここにスキーマがあります: – user3254924

答えて

0

がそれを手に入れたお試しください! 私はphpmyadminでこのメッセージを見ました: "列名 'to'はMySQL予約キーワードです。

だから私はそれをチェックし、ここから示唆されているように、 "backtickからのバックティック"を "from"に置き換えました。Syntax error due to using a reserved word as a table or column name in MySQL

ありがとうございます!

0

この

INSERT INTO ps_specific_price 
    (id_product, [reduction], [reduction_type] 
       , [from], [to]) 
VALUES (100145, 0.15, "percentage" 
        , cast ("2016-10-10 00:00:00" as datetime), cast ("2017-10-10 00:00:00" as datetime) 
+0

まだ動作していません... – user3254924

関連する問題