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 Quote Link to comment 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? Quote Link to comment Share on other sites More sharing options...
phpretard Posted July 15, 2008 Share Posted July 15, 2008 Use sessions Quote Link to comment 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 Quote Link to comment 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" Quote Link to comment 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" Quote Link to comment 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 Quote Link to comment 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` ) 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.