wrathican Posted November 20, 2008 Share Posted November 20, 2008 Hi there, Thanks for looking im trying to increment an int field with an sql query: update categories set blog_count='blog_count+1' where id='24'; my query runs sucessfully but does not increment the field. trying this on MySQL 4.0.20 i guess im either doing it wrong or my version doesnt support it. Help? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/133542-solved-updating-with-1/ Share on other sites More sharing options...
Mchl Posted November 20, 2008 Share Posted November 20, 2008 update categories set blog_count=blog_count+'1' where id='24'; Quote Link to comment https://forums.phpfreaks.com/topic/133542-solved-updating-with-1/#findComment-694602 Share on other sites More sharing options...
wrathican Posted November 20, 2008 Author Share Posted November 20, 2008 bah! as if it was that simple. i had been searching on google for about an hour trying to see where i was going wrong. none of the examples i saw put only the +1 in ' Thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/133542-solved-updating-with-1/#findComment-694609 Share on other sites More sharing options...
Mchl Posted November 20, 2008 Share Posted November 20, 2008 Well.. I suppose it;s because this: update categories set blog_count=blog_count+1 where id='24'; will work as well Quote Link to comment https://forums.phpfreaks.com/topic/133542-solved-updating-with-1/#findComment-694616 Share on other sites More sharing options...
corbin Posted November 21, 2008 Share Posted November 21, 2008 When dealing with numeric columns, the values should not be in quotes since they have to be parsed into numbers. Either way works though (in most cases). Quote Link to comment https://forums.phpfreaks.com/topic/133542-solved-updating-with-1/#findComment-694878 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.