rugzo Posted August 20, 2009 Share Posted August 20, 2009 Hi, i have a row which should be updated by every query. id sum 0 1 every time i run the query it should update the sum plus the new value. update x set sum = sum + $newvalue. this works fine. but how can i do that with explode. i need this because this column has to values which are seperated with "_". like 120_140. is it possible with sql query that i can do that. as example the current values are 120_140 the new values are 10_5 = 120+10_140+5 130_145 ? i know i can do that with php easyly but it must be done via the sql query in my structure ? thanks... Quote Link to comment https://forums.phpfreaks.com/topic/171131-mysql-explode-sum/ Share on other sites More sharing options...
suresh64633 Posted August 20, 2009 Share Posted August 20, 2009 Here is your query: In this i have added 1 to each 120 and 140. SELECT CONCAT(SUBSTRING('120_140',1,LOCATE( '_', '120_140' )-1)+1,'_',SUBSTRING('120_140',LOCATE( '_', '120_140' )+1,Length('120_140'))+1) as newValue Quote Link to comment https://forums.phpfreaks.com/topic/171131-mysql-explode-sum/#findComment-902530 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.