How do I delete the value of a specific column from all the rows in a table?

Discussion in 'MySQL' started by Imozeb, Apr 24, 2010.

  1. #1
    I want to delete the value from a group of columns (say column 1,2,3 and not 4,5,6) from all the rows (say a,b,c,d,e,f,g) in my table (u_table). How would I do this?

    I've been trying something with INSERT but I can't figure out how to do all the rows...
     
    Imozeb, Apr 24, 2010 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You need an UPDATE query. Most likely, since the value could be in any of 3 columns, you will need 3 update queries.
     
    plog, Apr 26, 2010 IP
  3. NemoPlus

    NemoPlus Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Actually, only 1 update query is sufficient.
    UPDATE u_table
    SET column_1='',
    SET column_2='',
    SET column_3=''
    Code (markup):
     
    NemoPlus, Apr 26, 2010 IP
  4. FriendSwapMeet.com

    FriendSwapMeet.com Peon

    Messages:
    67
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ^ +1 hit it on the head
     
    FriendSwapMeet.com, Apr 29, 2010 IP
  5. crashus

    crashus Active Member

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #5
    If amount of columns is low then use phpmyadmin, if not then you really need some condition
     
    crashus, May 6, 2010 IP