FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free 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
Related topics
HTTP AUTH with PHP and mySQL
Build an online dictionary by PHP/MySQL
Trying to restore database
Need Help integrating php variable into mySQL SELECT query
Caching Dynamic Images -- no luck
Formatting mySQL date
::e-MicroBar:: MicroBar [88x31] Ads - $100 Per Year
Pagination
Database connections failes after new month
MySQL Select
#2002 - The server is not responding (or the local MySQL ser
Frihost PHP Account
Possible to reduce minutes from PHP?
if statement
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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