woocha Posted July 15, 2008 Share Posted July 15, 2008 Hey Guys, I am not sure if this is possible or not, but am trying to update my MySQL db so that every row of one field is restored to its default vaue. If this is not possible, I would like to set the fields equal to a value. has anyone done this before, or does anyone know how to do this? Thanks guys Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/ Share on other sites More sharing options...
dannyb785 Posted July 15, 2008 Share Posted July 15, 2008 can you give an example of what you mean? Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591023 Share on other sites More sharing options...
phpretard Posted July 15, 2008 Share Posted July 15, 2008 Use sessions Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591025 Share on other sites More sharing options...
woocha Posted July 15, 2008 Author Share Posted July 15, 2008 I want to query my db table that has 325 rows of data. thats 325 users. Each users 'members' level is defaulted to 3 and some of them have changed. I wand to know if it is possible to update all 325 users to the default number 3 using a php script Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591075 Share on other sites More sharing options...
dannyb785 Posted July 16, 2008 Share Posted July 16, 2008 "UPDATE User SET user_level=3" that will update every single row's user_level to 3. if you want to hone the update a little more, end the query with "WHERE x=y" Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591302 Share on other sites More sharing options...
woocha Posted July 16, 2008 Author Share Posted July 16, 2008 What would this do? Because x!=y, it would update all of the rows? Is it safer to do it that way? end the query with "WHERE x=y" Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591437 Share on other sites More sharing options...
dannyb785 Posted July 16, 2008 Share Posted July 16, 2008 When I said x=y, it meant any possible conditional that would specify which rows get updated. Like "WHERE user_id = 5" or "WHERE user_fname='Bob' " or whatever. But if you leave out the WHERE part, it will update every single row with the stuff after SET Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591892 Share on other sites More sharing options...
discomatt Posted July 16, 2008 Share Posted July 16, 2008 To set to default UPDATE `table` SET `col` = DEFAULT( `col` ) Link to comment https://forums.phpfreaks.com/topic/114919-use-php-to-reset-one-field-to-default-value-in-every-row/#findComment-591901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.