Page 1 of 1

mysql syntax error - Load data

Posted: Sun Feb 04, 2007 8:42 pm
by aussie_clint
i cant seem to find where i'm going wrong with my syntax

can someone see what iv don

thanks

Code: Select all

LOAD DATA LOCAL INFILE '/home/computer/public_html/cwpriceCSV.csv'
INTO TABLE `newprice list`
FIELDS TERMINATED BY `,`
LINES TERMINATED BY `\n`

Posted: Sun Feb 04, 2007 8:51 pm
by feyd
What error are you getting?

Posted: Sun Feb 04, 2007 8:55 pm
by aussie_clint
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 ',`
LINES TERMINATED BY `\n`' at line 3

error 1064

Posted: Sun Feb 04, 2007 9:12 pm
by feyd
Should the last two strings be single quotes instead of backticks?

Posted: Sun Feb 04, 2007 9:14 pm
by aussie_clint
i tryed that

Posted: Sun Feb 04, 2007 9:19 pm
by feyd
Have you considered using fgetcsv()?

Posted: Sun Feb 04, 2007 9:44 pm
by aussie_clint
i have had this working before, iv just stuffed up and not sure what im doing wrong

Posted: Mon Feb 05, 2007 9:55 pm
by phpice
From the original post, it looks like you are using tick marks (`) instead of single quotes (') for the "terminated by" settings.

Posted: Mon Feb 05, 2007 10:27 pm
by aussie_clint
thanks, i fixed that up but im still gettinmg this error

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 ''newprice list'
FIELDS TERMINATED BY ','
LINES TERMINATED BY

Code: Select all

LOAD DATA LOCAL INFILE '/home/computer/public_html/cwpriceCSV.csv'
INTO TABLE 'newprice list'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'

Posted: Mon Feb 05, 2007 11:00 pm
by feyd
"newprice list" should be in backticks. Really, it shouldn't have a space in the name either... then it wouldn't require any backticks or quotes.