Skip to content

Instantly share code, notes, and snippets.

@fedir
Last active December 17, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fedir/5567014 to your computer and use it in GitHub Desktop.
Save fedir/5567014 to your computer and use it in GitHub Desktop.
An example of advanced import into MySQL database using LOAD DATA INFILE #mysql #csv
/**
*
* An example of advanced import into MySQL database using LOAD DATA INFILE
*
* import of first and second column from the file directly
* third column is equal to current datetime
* fourth column is transformed value of third column of csv file
* ref. : http://dev.mysql.com/doc/refman/5.1/en/load-data.html
*/
LOAD DATA INFILE 'file.txt'
INTO TABLE t1
(column1, column2, @var1)
SET column3 = CURRENT_TIMESTAMP, column4 = @var1/100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment