List:General Discussion« Previous MessageNext Message »
From:Johnny Withers Date:June 29 2009 2:04pm
Subject:Re: LOAD DATA INFILE Syntax error
View as plain text  
Group is a keyword in mysql:

You need to put backticks around it in your statement:

| LOAD DATA INFILE 'test.csv' INTO TABLE table
|   FIELDS TERMINATED BY ','
|   LINES STARTING BY '' TERMINATED BY '\n'
|   (Page, Device, `GROUP` , ItemID, Item, Value);


On Mon, Jun 29, 2009 at 7:07 AM, Ralph Kutschera <
news2008@stripped> wrote:

> Hallo List!
>
>  I have a CVS file which i would like to import to MySQL.
>
> The file header and an example:
> | Page,Device,Group,ItemID,Item,Value
> | Overview,General,Computer,513,OS,Linux
>
>
> The table has:
> | Create Table: CREATE TABLE `table` (
> |   `ID` int(11) NOT NULL auto_increment,
> |   `Page` varchar(128) default NULL,
> |   `Device` varchar(128) default NULL,
> |   `Group` varchar(128) default NULL,
> |   `ItemID` varchar(128) default NULL,
> |   `Item` varchar(128) default NULL,
> |   `Value` varchar(128) default NULL,
> |   PRIMARY KEY  (`ID`)
> | ) ENGINE=MyISAM DEFAULT CHARSET=latin1
>
>
> So I would like to import the first file field to the second table field,
> the second file field to the third table,... Just to have an index.
>
> I'm using:
> | LOAD DATA INFILE 'test.csv' INTO TABLE table
> |   FIELDS TERMINATED BY ','
> |   LINES STARTING BY '' TERMINATED BY '\n'
> |   (Page, Device, GROUP , ItemID, Item, Value);
>
>
> which gives me:
> | #1064 - 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 'Group, ItemID, Item, Value)' at line 2
>
> I cannot find the error. Please help me!
> MySQL version = 5.0.32-Debian_7etch8-log
>
> TIA,
>  Ralph
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


-- 
-----------------------------
Johnny Withers
601.209.4985
johnny@stripped

Thread
LOAD DATA INFILE Syntax errorRalph Kutschera29 Jun
  • Re: LOAD DATA INFILE Syntax errorJohnny Withers29 Jun
    • Re: LOAD DATA INFILE Syntax errorRalph Kutschera29 Jun