alexguz79 Posted July 6, 2010 Share Posted July 6, 2010 Greetings!!! I know if i want the SUM of al the values in a row i jus do 'SELECT SUM(row) AS row_total FROM table' but how about if i want to substract the values? ex: 2-2-3-1-4 what should i use? thanks Link to comment https://forums.phpfreaks.com/topic/206897-math-operations/ Share on other sites More sharing options...
Mchl Posted July 6, 2010 Share Posted July 6, 2010 Add - in front? Link to comment https://forums.phpfreaks.com/topic/206897-math-operations/#findComment-1081942 Share on other sites More sharing options...
ChemicalBliss Posted July 6, 2010 Share Posted July 6, 2010 I think you woudl have to do this in PHP, doubt mysql has that feature - but why would you want to do this? anyway something like this after that query: $row_total = $row['row_total']; $inverted = 0 - $row_total; -cb- Link to comment https://forums.phpfreaks.com/topic/206897-math-operations/#findComment-1081943 Share on other sites More sharing options...
alexguz79 Posted July 6, 2010 Author Share Posted July 6, 2010 thanks... i'll try that Link to comment https://forums.phpfreaks.com/topic/206897-math-operations/#findComment-1081944 Share on other sites More sharing options...
Mchl Posted July 6, 2010 Share Posted July 6, 2010 I think you woudl have to do this in PHP, doubt mysql has that feature - but why would you want to do this? anyway something like this after that query: $row_total = $row['row_total']; $inverted = 0 - $row_total; -cb- How is that different from SELECT -SUM(row) AS row_total FROM table or SELECT SUM(-row) AS row_total FROM table or even $inverted = -$row_total; ? Link to comment https://forums.phpfreaks.com/topic/206897-math-operations/#findComment-1081984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.