joecooper Posted August 30, 2011 Share Posted August 30, 2011 I have a value that in parts of my code i need to update. Its a number value, stored as TEXT. which i need to add numbers to it, at the moment I am using this to get the current value: $sql2="SELECT * FROM weekly LIMIT 1"; $result2=mysql_query($sql2); $row2 = mysql_fetch_array( $result2 ); $rollingjackpot = $row2['rollingjackpot']; then i am adding the value to the varible, then using UPDATE to update it again, cant this be done in a simple query? something like: $query = mysql_query("UPDATE weekly SET `rollingjackpot` + $amount WHERE `id` = '1'") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/246038-can-you-update-a-mysql-value-within-the-query/ Share on other sites More sharing options...
MarPlo Posted August 30, 2011 Share Posted August 30, 2011 Hy, I think this query is good: "UPDATE weekly SET `rollingjackpot`=`rollingjackpot`+$amount WHERE `id` = 1" Quote Link to comment https://forums.phpfreaks.com/topic/246038-can-you-update-a-mysql-value-within-the-query/#findComment-1263590 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.