Add new record, is it possible?

Discussion in 'Databases' started by edhan, Jul 12, 2007.

  1. #1
    Hi

    Need advice as whether is it possible to add new record to existing database.

    Currently I have existing database ID record for 1000. Now I am thinking of adding a new record of 100 quotes but repeats itself 10 times to fill up the existing 1000 records. It means that I will add 1 to 100 and repeats 101 to 200 with the same records until it fills up 1000 records.

    Is this possible? How can I insert this new records to repeat itself 10 times? I was thinking of using phpMyAdmin to add one by one by that is too time consuming so if I can issue a command to generate 100 new records to be added and repeats itself until the 1000 records is filled up, this will be the best solution.

    If anyone can help, green rep will be given.

    Thanks!
     
    edhan, Jul 12, 2007 IP
  2. Synch

    Synch Peon

    Messages:
    76
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    create another table with an auto increment field for the id, run the below insert with all 10 fields that you want into the new table 10x. Then turn off the auto increment on the old table and insert all of the new records into the old table.

    example:

    
    
    insert into tablename (value1,value2,value3)
    values
    ('first','first','first'),
    ('2','2,'2'),
    ('3','3','3'), ... 7 more times
    
    once that table is filled
    
    insert into old_table (id,value1,value2,value3)
    select * from new_table
    
    
    
    
    PHP:
    This will be a lot faster then doing each record by hand.
     
    Synch, Jul 12, 2007 IP
  3. edhan

    edhan Active Member

    Messages:
    364
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Still Unsolved.

    Use the command REPLACE:

    REPLACE INTO `post_status` (`quote`) VALUES
    ('What are you doing'),
    ('Love is in the air'),
    ('Help is on its way'),
    ('What can I do for love'),
    ('Loving you forever');

    Ended up and other data being replace and only showing quote.

    Any idea how I can add into existing 1000 records without erasing the data?
     
    edhan, Jul 12, 2007 IP