In a bit of a quandary here...

I have a user table and a registered serials table
Table data at end of email...

I have been given a large set of new data, but it is flat file, basically,
it looks just like the user table, with the addition of one field called
serial.

Somehow, I need to take the 100K or so records, which are currently in a
table that is called user_tmp and has the exact same structure as user with
one additional field called serial, copy each field from the user_tmp to the
user table, which should auto-inc the id field, then copy the serial from
the user_tmp table along with the id, and put those in the
Registered_serials, with serial going into serial, and is into user_id.

When all is said and done, I would hope both tables still have the same
number of records in them.

I was going to script this out, but the sheer volume of records make me
think it could fail.

user
+-------------+---------------+------+-----+---------+----------------+
| id          | int(11)       |      | PRI | NULL    | auto_increment |
| username    | varchar(16)   |      |     |         |                |
| password    | tinyblob      |      |     |         |                |
| session     | varchar(32)   |      |     |         |                |
| first_name  | varchar(48)   |      |     |         |                |
| middle_name | varchar(32)   |      |     |         |                |
| last_name   | varchar(48)   |      |     |         |                |
| name        | varchar(255)  |      |     |         |                |
| company     | varchar(96)   |      |     |         |                |
| department  | varchar(96)   |      |     |         |                |
| address     | varchar(128)  |      |     |         |                |
| address2    | varchar(128)  |      |     |         |                |
| city        | varchar(64)   |      |     |         |                |
| state       | varchar(64)   |      |     |         |                |
| country     | varchar(64)   |      |     |         |                |
| zip         | varchar(64)   |      |     |         |                |
| phone       | varchar(48)   |      |     |         |                |
| fax         | varchar(48)   |      |     |         |                |
| email       | varchar(40)   |      |     |         |                |
| active      | char(1)       |      |     | 0       |                |
| updated     | timestamp(14) | YES  |     | NULL    |                |
| added       | timestamp(14) | YES  |     | NULL    |                |
+-------------+---------------+------+-----+---------+----------------+

Registered_serials
+----------+---------------+------+-----+---------+----------------+
| Field    | Type          | Null | Key | Default | Extra          |
+----------+---------------+------+-----+---------+----------------+
| id       | int(11)       |      | PRI | NULL    | auto_increment |
| user_id  | int(11)       |      |     | 0       |                |
| serial   | varchar(20)   |      |     |         |                |
| product  | varchar(4)    |      |     |         |                |
| updated  | timestamp(14) | YES  |     | NULL    |                |
| added    | timestamp(14) | YES  |     | NULL    |                |
+----------+---------------+------+-----+---------+----------------+
-- 
-------------------------------------------------------------
Scott Haneda                                Tel: 415.898.2602
http://www.newgeo.com                       Fax: 313.557.5052
[EMAIL PROTECTED]                            Novato, CA U.S.A.


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

Reply via email to