SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot JordanTLClive's Avatar
    Join Date
    Feb 2001
    Location
    Las Vegas, NV
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Renovating" a Database - How to copy data?

    I'm trying to modify an old maillist list database so that it will work with multiple lists. What I'm doing is taking one table which stored the user id, email, zip, join date, and a variable for whether or not the user could recieve html email, and I'm converting it to 3 tables, one is the mailling list's, another is the users, and the third is the linking table which links a user to a mailling list. I need to copy all the users fromt he original table to the new users table. How can I do this?

    Database structure:

    original table:
    +----------+-------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------+-------------+------+-----+---------+----------------+
    | id | int(11) | | PRI | 0 | auto_increment |
    | email | text | | | NULL | |
    | listname | text | YES | | NULL | |
    | joindate | date | YES | | NULL | |
    | zip | varchar(10) | YES | | NULL | |
    | html | tinyint(1) | YES | | NULL | |
    | mln | int(11) | YES | | NULL | |
    +----------+-------------+------+-----+---------+----------------+

    new user table:
    +----------+-------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------+-------------+------+-----+---------+----------------+
    | id | int(11) | | PRI | 0 | auto_increment |
    | email | text | | | NULL | |
    | joindate | date | YES | | NULL | |
    | zip | varchar(10) | YES | | NULL | |
    | html | tinyint(1) | YES | | NULL | |
    +----------+-------------+------+-----+---------+----------------+
    -Jordan

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How many records are in that table? If its not going to hammer the server too hard, I would just write a script that churns through the data in the old table and inserts the relevent columns into the new one:
    ie,

    SELECT id, email, joindate, zip, html FROM oldtable

    Then for each record in the result set

    INSERT INTO newtable VALUES ($id, $email, $joindate, $zip, $html)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •