3

How to use file load query?

I tried this query:

LOAD DATA INFILE 'customer.csv' INTO TABLE customer
manlio
  • 18,345
  • 14
  • 76
  • 126
Chetan
  • 51
  • 6
  • Do you get an error message? – Philipp Oct 20 '16 at 10:50
  • Also, depending on the error (if any), include a snippet of the csv file and the structure of the customer table. – Robba Oct 20 '16 at 10:56
  • 3
    Possible duplicate of [How to import CSV file to MySQL table](http://stackoverflow.com/questions/3635166/how-to-import-csv-file-to-mysql-table) – Smita Ahinave Oct 20 '16 at 11:04
  • in csv i have an address column in which ',' occur because of this in my mysql table data move one column to another column. – Chetan Oct 20 '16 at 12:21

1 Answers1

2

Syntax:

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name' INTO TABLE `tbl_name` CHARACTER SET [CHARACTER SET charset_name] FIELDS [{FIELDS | COLUMNS}[TERMINATED BY 'string']] [LINES[TERMINATED BY 'string']]

Example:

LOAD DATA LOCAL INFILE 'E:\\wamp\\tmp\\customer.csv' INTO TABLE `customer` CHARACTER SET 'utf8' FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'
Liam
  • 27,717
  • 28
  • 128
  • 190
Md. Nashir Uddin
  • 730
  • 7
  • 20
  • ENCLOSED BY '"' solve my ',' occur problem. Thanks :) – Chetan Oct 20 '16 at 13:35
  • Please read [How do I format my code blocks?](http://meta.stackoverflow.com/questions/251361/how-do-i-format-my-code-blocks) – Liam Oct 24 '16 at 14:46