FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

MYSQL SELECT

 


ftv_flung
I'm trying to get MySQL to only change the data of ONE of their (the user that is logged in) rows and change it with UPDATE - is there a way of doing this? It keeps updating EVERYONE's row!

I have been getting help from this tutorial where it says

Quote:
Now it is important to note that this query would have updated ALL records that had an age of 21 to the new age of 22. In a table where Sandy is not the only entry, this may become a problem, and a more sophisticated solution would be necessary.


What is the workaround for this?


Thanks for any help, in advance!
rvec
add a where part
you rpobably use something like this:
Code:
UPDATE table_name
SET column_name = new_value


Instead use this:
Code:
UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value


In your example you can make it look like this:
Code:
UPDATE users
SET age = '22'
WHERE name='Sandy' AND age='21'
ftv_flung
Thanks very much for your help rvec! Got it working Smile
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.