Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Quoting mis-understanding

Quoting mis-understanding

2007-06-19       - By tazatek

 Back
Reply:     1     2  


Hello,

The gist of my problem is this:  I load data from a CSV file into a table.
The fields are unquoted.  I then read back parts of this table to create a
new table.  The problem is that the table that gets created is requiring
backticks because the import of data from a table to create another table is
quoting.

Let me explain via code:

// load data from CSV file into property_map table
q << "load data infile '/home/matt/map.csv' into table property_map fields
terminated by ',' ";

 q << "select * from  property_map";
 Result res = q.store();
    q.reset();
    q << "create table property_temp( ";
     Row row;
     Row::size_type i;
     for (i=0; row = res.at(i); ++i)
  {
            // notice the required backticks
       q << "`" << row.at(2) << "` varchar(" << row.at(3) << ") NOT NULL
default '', ";
       }
     q << "PRIMARY KEY (`" << res.at(0).at(2) << "`) ) ENGINE=InnoDB;";
    q.execute();

-- ---- ---

When I do a select * from property_map the fields are all quoted, and in the
mysql client, I have to use backticks to use the fields.


What am I doing wrong??   Is my Load Data command wrong?  Is my CSV format
wrong?  Am I trying to create the table incorrectly? ( NB:  This isn't my
preferred way to create a table.  I am forced to use a legacy system that
has there tables set up this way)

Any help is appreciated.

Thanks

Matt




--
View this message in context: http://www.nabble.com/Quoting-mis-understanding
-tf3948838.html#a11202678
Sent from the MySQL - C++ mailing list archive at Nabble.com.


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus?unsub=mysql@(protected)