LOAD DATA INFILE Syntax error

LOAD DATA INFILE Syntax error

am 29.06.2009 14:07:43 von Ralph Kutschera

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=gcdmg-mysql-2@m.gmane.org

Re: LOAD DATA INFILE Syntax error

am 29.06.2009 16:04:35 von Johnny Withers

--000e0cd24a5a870096046d7d2b47
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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@ecuapac.dyndns.org> 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=johnny@pixelated.net
>
>


--
-----------------------------
Johnny Withers
601.209.4985
johnny@pixelated.net

--000e0cd24a5a870096046d7d2b47--

Re: LOAD DATA INFILE Syntax error

am 29.06.2009 16:19:21 von Ralph Kutschera

Johnny Withers schrieb:
> 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);

Ooookay. Thank you very much!


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org