开发者

Help with LOAD DATA INTO FILE

I have a database setup like

  `id` int(11) unsigned NOT NULL auto_increment,
  `ad-id` int(11) default NULL,
  `advertiser-id` int(11) default NULL,
  `advertiser-name` varchar(250) default NULL,
  `advertiser-category` varchar(250) default NULL,
  `buy-url` varchar(255) default NULL,
  `catalog-id` varchar(255) default NULL,
  `currency` varchar(3) default NULL,
  `description` varchar(255) default NULL,
  `image-url` varchar(255) default NULL,
  `in-stock` varchar(255) default NULL,
  `isbn` varchar(13) default NULL,
  `manufacturer-na开发者_开发技巧me` varchar(255) default NULL,
  `manufacturer-sku` varchar(50) default NULL,
  `name` varchar(255) default NULL,
  `price` decimal(10,2) default NULL,
  `retail-price` decimal(10,2) default NULL,
  `sale-price` decimal(10,2) default NULL,
  `sku` varchar(50) default NULL,
  `upc` varchar(50) default NULL,

I am trying to load the data like this:

LOAD DATA LOW_PRIORITY LOCAL INFILE "/home/datafeed/tempfile.csv" REPLACE INTO TABLE products_import FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY """" LINES TERMINATED BY "\n" (ad-id, advertiser-id, advertiser-name, advertiser-category, buy-url,catalog-id,currency, description,image-url,in-stock,isbn,manufacturer-name,manufacturer-sku,name,price,retail-price,sale-price,sku, upc);

but it doesn't seem to like database names with dashes in them. The field names are pretty much set in stone. If I try to insert without the field names it sets everything in the wrong field (starts with autoinc)

I'm not very good with MySQL any help would be appreciated.


Put back-ticks around the field names: `ad-id`, etc., like in your table structure listing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜