PDA

View Full Version : Query help


filburt1
03 Apr 2004, 16:49
I have a table with (for simplification) three columns: fromuserid, touserid, and amount. I want to find the sum of amount, but it is governed by the following (using 13 as a sample userid):


If touserid is 13, then add the amount to the sum
If fromuserid is 13, then subtract the amount from the sum

How would I do this?

Dean C
03 Apr 2004, 17:14
Why not do your calculations outside of the query using PHP - makes for faster processing time :)

Xenon
03 Apr 2004, 19:13
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



that should work i think

filburt1
03 Apr 2004, 19:46
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------



that should work i think
Close, got it working with this, thanks:


Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------

Xenon
03 Apr 2004, 19:52
oops, i forgot that you ahve a special col with the ammount ;)