hostfreak Posted August 6, 2006 Share Posted August 6, 2006 Recently I have just discovered that I had a default of 0 set on a mysql field (if nothing was selected on the form for the field, it would then go to 0), when it should have had a default of nothing if nothing was selected on the form. So what would be the best way for me to go about updating it? I need the ones that contain 0 to be changed to where they are blank. There are a lot of rows, otherwise I would just manually edit them from phpmyadmin. I was thinking this could be done via making a page that selected the field where it had a value of 0. Then making a form that doesn't receive a value and then update it that way? I am not 100% sure how to go about that though. The table name that the field is in, is "users". The field is "id2". Thanks in advance for any replies. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 6, 2006 Share Posted August 6, 2006 just run this query in your phpamyadmin. MAke sure that the fields CAN be null otherwise it will fail.UPDATE `table_name` SET `field` = NULL WHERE `field` = 0; Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 6, 2006 Author Share Posted August 6, 2006 That did the trick, thanks Toon Mariner. Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted August 6, 2006 Share Posted August 6, 2006 And when you want to change the default of that column you have to do[code]ALTER `table_name` ALTER `field` SET DEFAULT NULL[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.