table filling

Discussion in 'PHP' started by playwright, Jul 15, 2010.

  1. #1
    Is there a way to fill one column of a table and afterwards fill the rest columns??For example i have a table : abc('id','a','b','c') and i want to fill first the column 'id' and 'c' (where id is the primary key) with elements and then fill the other columns.. As a result i want to have all rows filled with all elements but is this possible to do it in 2 steps???
     
    playwright, Jul 15, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, it's possible. Use INSERT with blank values:
    
    INSERT INTO abc(`id`, `a`, `b`, `c`) VALUES(1, '', '', 'Some text');
    
    Code (markup):
    (if your primary key is auto-incrementing, then leave out the 'id' field or give it the value of NULL)




    Then use UPDATE to fill in the blanks the second time around:
    
    UPDATE abc SET `a` = 'More text', `b` = 'Even more text' WHERE id = 1;
    
    Code (markup):
     
    Deacalion, Jul 15, 2010 IP