View Full Version : Newbie with mysql
I want to change all the data in mysql database field from Away to Normal. What is the proper mysql command to do this?
Somehow all the members vacation settings in my safelist got changed to Away and I want to change them all back to Normal at one time.
tsl001
UPDATE `nameoftable` SET `value`='Normal' WHERE `value`='Away'
I hope you understand.
I need to update the field data not the table. What is the command to update all data in a field?
tsl001
senegalo
04/12/2005, 06:27
Hello there,
well i didn't quite understand you but..
it's exactly like slava told you..
or its
update tableName set `fieldName` = 'newValue' where `anotherOrSameField` = 'aCertainValue'
for example if i want to update the password or a user in a username/password table that's what i would do...
update users set `password` = 'newPassword' where `password` = 'oldPassword'
OR
update users set `password` = 'newPassword' where `username` = 'senegalo'
if you want to update more than one field at a time just do as follow...
update users set `password` = 'newPassword', `username` = 'newUsername' where `id` = '5'
HINT: you must have a unique field for each row... in the example above it was the username (" usernames are unique ") if it happends that in your table you are not sure if there is a unique field in the entire table you just use the id which is a number that auto ++ every row giving you a unique value to identify each row...
Hope you understood something from what i said :)
Seems to you do not understanding fully DB's structures...
Main thing is DB, then in DB can be created tables, each table have a columns, row is a number of values in columns.
Thanks I got it:
This is the command I used
update safelist set `Vacation` = 'Normal' where `Vacation` = 'Away';
tsl001
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.