Date |Mon, 6 Aug 2001 13:48:41 -0700
>From |[EMAIL PROTECTED]
Hello!
C> I have a table I want to import some records into. The table has 4 columns
C> -
C> user_id, name, account, password.
C> The file I have to be imported has 3 columns -
C> password,name,account.
C> I have been trying to use load data infile and keep ending up with a lot of
C> junk in the database.
C> The file is of this format -
C> password,name,account
C> password,name,account
C> etc
C> File name is users and table name is users.
mysql>> load data infile '/usr/home/chip/users' into table users
C> -> (name,password,account)
C> -> fields terminated by ',';
C> ERROR 1064: You have an error in your SQL syntax near 'fields terminated by ','' at
l
C> ine 3
mysql>>
You need to use right LOAD DATA syntax.
LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
[TERMINATED BY '\t']
[[OPTIONALLY] ENCLOSED BY '']
[ESCAPED BY '\\' ]
]
[LINES TERMINATED BY '\n']
[IGNORE number LINES]
[(col_name,...)]
So, columns name must be at end of query
LOAD DATA INFILE '/usr/home/chip/users'
fields terminated by ','
INTO TABLE users (name,password,account)
___________________________________________________________________
For technical support contracts, visit https://order.mysql.com/
This email is sponsored by SWSoft, http://www.asplinux.ru/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Grigory Bakunov <[EMAIL PROTECTED]>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB / SWSoft
/_/ /_/\_, /___/\___\_\___/
<___/ www.mysql.com
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php