472,353 Members | 983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

LOAD DATA INFILE Syntax Error

I am attempting to import a large file with data in this format:

1923158|GA|1996 Olympic Yachting
Cauldron|park|Chatham|13|051 |320446N|0810502W|32.07944|-
81.08389||||||||Savannah

With this command:
LOAD DATA LOCAL INFILE 'C:\\PHP\\FL_DECI.txt'
INTO TABLE locations2
FIELDS TERMINATED BY '|'
LINES TERMINATED BY "\r"
(@d,@d,LOCNAME,LOCTYPE,@d,STATE,COUNTY,@d,@d,LNG,L AT,@d,@d,@d,@d,@d,@d,@d,@=
d);

The @d is a dummy variable for information I do not need to import. The
table structure looks like this:

+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| ID | int(11) | | PRI | NULL | auto_increment |
| STATE | int(11) | YES | | NULL | |
| LOCNAME | varchar(25) | YES | | NULL | |
| LOCTYPE | varchar(10) | YES | | NULL | |
| COUNTY | int(11) | YES | | NULL | |
| CTRLAT | float | YES | | NULL | |
| CTRLNG | float | YES | | NULL | |
+---------+-------------+------+-----+---------+----------------+

And here is the error I get:

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
'@d,@d
,LOCNAME,LOCTYPE,@d,STATE,COUNTY,@d,@d,LNG,LAT,@d, @d,@d,@d,@d,@d,@d,@d)'
at
line
5

This error is driving me nuts! Any help would be appreciated, as this
is a
rather large file.

Jason

Sep 27 '05 #1
1 5885
DartmanX wrote:
LOAD DATA LOCAL INFILE 'C:\\PHP\\FL_DECI.txt'
INTO TABLE locations2
FIELDS TERMINATED BY '|'
LINES TERMINATED BY "\r"
(@d,@d,LOCNAME,LOCTYPE,@d,STATE,COUNTY,@d,@d,LNG,L AT,@d,@d,@d,@d,@d,@d,@d,@=
d);

The @d is a dummy variable for information I do not need to import.


Are you using MySQL 5.0.3 or later? Putting imported data into user
variables is not supported in releases earlier than 5.0.3, according to
this page:
http://dev.mysql.com/doc/mysql/en/load-data.html

"As of MySQL 5.0.3, the column list can contain either column names or
user variables..."

If you're using an earlier release of MySQL, I'd suggest creating a
temporary table with enough columns to store all the fields in your txt
file, and then once it's imported, you can copy the columns you need to
your locations2 table with INSERT...SELECT.

Another option is that you could install a copy of the latest MySQL 5.0
release candidate on another computer (or the same computer, if you're
feeling intrepid about maintaining two instances of MySQL on one host),
then import your text file using the @d dummy variables technique, then
make a SQL dump file of the resulting table, so it's easier to import to
your 'real' MySQL instance.

Regards,
Bill K.
Sep 27 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Bruce A. Julseth | last post by:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)" $File =...
3
by: Otto | last post by:
Hello to all I have a problem how to write correctly a PHP string. I did the following import with the help of PHPMyAdmin: Nombre...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL...
1
by: Jami Bradley | last post by:
HI all, For the past several months we have been using LOAD DATA LOCAL INFILE to bulk load tables within Perl modules. Recently, someone...
0
by: Rajesh Kapur | last post by:
Hello, I am running MySQL 4.0.16. I get the error 'The used command is not allowed with this MySQL version' when using the 'load data local...
2
by: Alex Hunsley | last post by:
I'm using a mysql monitor under cygwin (on win xp) to do a 'load data infile' to put some data into a mysql database (I'm using the xampp bundle).....
1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA...
3
by: chamindas | last post by:
$singlequote ="\'"; $myquery="load data local infile '$filename' replace into table $tablename fields terminated by ';' enclosed by '$doublequote'...
0
by: lanesbalik | last post by:
hi all, right now i'm trying to migrate from db2 running under linux to mysql v5.1. i manage to export out the db2 structure & data into a...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.