If I understand correctly, your text file does not have an ID for each row, but the table does have an ID column. Good. Your table should have the record ID column defined as AUTO_INCREMENT. Something like

CREATE TABLE table_name (
  ID int NOT NULL PRIMARY KEY AUTO_INCREMENT,
  other column definitions...

In that case, simply leave ID out of the columns you are importing to have mysql automatically fill in the ID with unique values. That's the point of AUTO_INCREMENT. The AUTO_INCREMENT column gets a unique number assigned by mysql if you leave it out or if you assign it the (non) value NULL.

See

"Using AUTO_INCREMENT"
  <http://www.mysql.com/doc/en/example-AUTO_INCREMENT.html> and

"CREATE TABLE Syntax",
  <http://www.mysql.com/doc/en/CREATE_TABLE.html>

and "mysqlimport, Importing Data from Text Files"
  <http://www.mysql.com/doc/en/mysqlimport.html>

in the manual for more.

Michael

Bob Cohen wrote:

Sorry in advance for the dumb newbie question but . . . I'm using a
content management system and want to avoid the hassle of entering data
by hand when I've already got it in a delimited text file.  I get the
basic concept of using mysqlimport.  However, the source file's data
doesn't match the target file's structure.  Of particular concern for me
is that the target table has record id files the would need to be
incremented.

I get the task on the conceptual level.  E.g., map the incoming columns
with the appropriate fields in the target table and increment the record
id number.  I'm a web designer not a programmer. I'm not at all sure how
to accomplish this task. Though I would like to learn.

Any help would be appreciated. Thanks.

Bob Cohen
b.p.e.Creative
http://www.bpecreative.com
Design and production services for the web
Put creative minds to work for you




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to