Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading table with .txt file wont work 1

Status
Not open for further replies.

remvs

Technical User
Sep 22, 2003
18
NL
Hi all,
i'm trying to loda a textfile into a tabel (called login) with this sql-string:

[blue]load data local infile 'C:\\login.txt' into table login(login,pwd) LINES TERMINATED BY '\r\n';[/blue]

But all i get is an error saying that i have a typo in my SQL string.

Weird thing is that when i remove the ' (login,pwd) part, it WILL read it, but then the tables are all wrong (coz i also have an autoincrement in first column)

Any tips please?!

Thanks in advance!
Remvs
 
how are the field separated? comma? space? tab?
if comma, add a comma at the first char in the line

now:
user,pwd

after:
,user,pwd

just a thought
 
Drop the word "LOCAL". "LOCAL" is used in situations where you are transmitting the file to be inserted from the client to the server through the connection.

Also, as stated in the MySQL online manual page for LOAD DATA INFILE, the part of the query which states into which table columns the data should go (the "(login,pwd)" part of your query) goes at the end of the query, not the middle.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
also all flavours of MySQL seem to prefer the unix style paths :
c:/path/to/file.txt

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
hi all,

I have fixed it thanks to sleipnir214's help:

Indeed i had to put the '(name,pwd)' at the end of the line.


thanks alot all of you!!
And sleipnir214, you earned yourself another star :)

Remvs
From Holland
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top