myristate Posted March 20, 2011 Share Posted March 20, 2011 This is fairly simple stuff im about to ask (well i hope it is) I have included a screen shot of my how my table looks from phpmyadmin as i fear my explanation following might suck a bit. Anyway i have a coloum there called "Colour" in it there are four possible colours "red/yellow/blue/white" It has come to my attention that some of the colours for some of the data entries are wrong so my question is how do i update say all the "red" coloured items in that coloum without effecting the other colours. I thought this might possibly do it. However i cant afford to run it without knowing if it will work or not. : "UPDATE $db_table SET colour = 'Blue' WHERE colour = 'Red' "); [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/231183-updating-values-in-coloum/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 20, 2011 Share Posted March 20, 2011 i cant afford to run it without knowing if it will work ^^^ That's why you would do this on some test data first. In programming, it's generally going to take you a lot less time to make a test case and try your solution so that you can conform if it does what you expect, than what it will take to post a question in a forum somewhere and hope you get an accurate answer to your question. And if this is a one time update, you can just do it directly in phpmyadmin without needing to write any php code. Quote Link to comment https://forums.phpfreaks.com/topic/231183-updating-values-in-coloum/#findComment-1189933 Share on other sites More sharing options...
myristate Posted March 20, 2011 Author Share Posted March 20, 2011 While i appreciate what your saying and of course it makes sense. I was kind of in a hurry and did not want the hassle of setting up another test server. I had a backup so in reality if it had gone wrong it wasnt the end of the world Quote Link to comment https://forums.phpfreaks.com/topic/231183-updating-values-in-coloum/#findComment-1189992 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.