The Little Guy Posted February 16, 2007 Share Posted February 16, 2007 Is it possible to update a field by adding a number 1-10? Example: say the filed currently has a number of 1230, and I want to add 10 to that field, the new filed will now hold 1240 How can I do that without doing 2 queries? Oh yeah, this would be using the UPDATE sql Link to comment https://forums.phpfreaks.com/topic/38721-solved-add-1-10-more-to-a-mysql-filed/ Share on other sites More sharing options...
jcbarr Posted February 16, 2007 Share Posted February 16, 2007 UPDATE table SET column=(column+10) WHERE column='value' something like that would work. Not sure exactly the context in which you need to use this, but that should work. Link to comment https://forums.phpfreaks.com/topic/38721-solved-add-1-10-more-to-a-mysql-filed/#findComment-186034 Share on other sites More sharing options...
The Little Guy Posted February 16, 2007 Author Share Posted February 16, 2007 Thanks, I'll give it a try Link to comment https://forums.phpfreaks.com/topic/38721-solved-add-1-10-more-to-a-mysql-filed/#findComment-186037 Share on other sites More sharing options...
The Little Guy Posted February 16, 2007 Author Share Posted February 16, 2007 That worked 90%, but then I modified it to work 100%. I removed the single quotes, and the parenthesis and it worked then $sql = mysql_query("UPDATE snippets SET voteTotal=voteTotal+$vote, votes=votes+1 WHERE id='$id'")or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/38721-solved-add-1-10-more-to-a-mysql-filed/#findComment-186054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.