1

This is my command line query.

mysql> load data local infile "c:\\re\\30-11-08.csv" 
into table powerdata(Date, DG1, DG2, DG3, Dg4, DG5, ChillerPanel1, 
    ChillerPanel2, ChillerPanel3, ChillerPanel4,1st_Floor, 2nd_Floor, 
    3rd_Floor, 4th_Floor, UPS1, UPS2, UPS3, UPS4, UPS5,Server_Power, 
    Cooling_Power) 
    fields terminated by ',' lines terminated by '\n'
set Dateformat=str_to_date(Date, '%m/%d/%Y' '%H:%i:%s');

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fields terminated by ',' lines terminated by '\n'set Dateformat=str_to_date(Date' at line 1

I do not know where the error is! Can anyone help me?

1
  • i have mysql 5.0 . to support set clause which one shall i download Commented Mar 10, 2009 at 11:52

1 Answer 1

2

I suppose the "set Dateformat=" part is causing the problem. Your column is named "Date" so that part should look like:

set Date = str_to_date(@datevar, 'your format')

Also see the following code sample in the manual:

LOAD DATA INFILE 'file.txt'
  INTO TABLE t1
  (column1, @var1)
  SET column2 = @var1/100;

BTW: before MySQL 5.0.3 the SET clause is not supported.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.