mforan Posted March 7, 2009 Share Posted March 7, 2009 is there a way to UPDATE table name SET then default value in the database? like name = the default value in db? Link to comment https://forums.phpfreaks.com/topic/148393-update/ Share on other sites More sharing options...
Mchl Posted March 7, 2009 Share Posted March 7, 2009 I guess it is... you'd have to get the default value from table definition first using DESCRIBE `table` http://dev.mysql.com/doc/refman/5.1/en/describe.html Link to comment https://forums.phpfreaks.com/topic/148393-update/#findComment-779140 Share on other sites More sharing options...
mforan Posted March 7, 2009 Author Share Posted March 7, 2009 so theres no way to just update the database without first selecting the database default values in a prior mysql command? that seems kinda stupid really, what if you have 100's of columns? Link to comment https://forums.phpfreaks.com/topic/148393-update/#findComment-779150 Share on other sites More sharing options...
Mchl Posted March 7, 2009 Share Posted March 7, 2009 Why would you want to update 100s of columns to default values? Why would you HAVE 100s of columns in the first place? Link to comment https://forums.phpfreaks.com/topic/148393-update/#findComment-779156 Share on other sites More sharing options...
mforan Posted March 7, 2009 Author Share Posted March 7, 2009 lol i have 108 columns in my database and growing. as for this, belive it or not, this works: UPDATE tablename SET name ='DEFAULT'; somethings are so simple minded >_< lolz Link to comment https://forums.phpfreaks.com/topic/148393-update/#findComment-779161 Share on other sites More sharing options...
Mchl Posted March 7, 2009 Share Posted March 7, 2009 I think it should be without qoutes. With qoutes it sets the value to literal string. UPDATE tablename SET name = DEFAULT; Other than that: cool! Didn't know that. Having 100 or more columns within one table suggests that your database design is not normalised. Maybe you should review it? Link to comment https://forums.phpfreaks.com/topic/148393-update/#findComment-779175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.