[eluser]mvdg27[/eluser]
Hi guys,
for a project I'm working on now, I have to do a database query, and I'm having difficulties to figure out how to get the correct results. Maybe someone here could shed his light on the case
Ok. I have a very simple database setup:
id|username|number|donation
It's a script where people can virtually donate to a good cause. For each 'number', the organization donates 2 Euro's to one out of three causes (donation = 1, 2, or 3).
So the simplest way of doing this for each cause is:
Code:
"SELECT SUM(number * 2) AS cause1 FROM table WHERE donation = 1";
However, there an extra condition, that makes it a bit harder:
The maximum amount that one user (username) can donate is 10 Euro's. But it can be donated in different rows and to different causes.
How would you guys go about doing this?
Any advice is very much appreciated!
-Michiel