A join and a SUM() |
[eluser]webnology[/eluser]
Hi all, I have a table with arrangements, and a table which keeps the revenue per arrangement. I'm trying to show a table of all arrangements with their total revenue. I have this code: Code: $this->db->select('arrangements.*, SUM(revenue.arrangement_price) as revenue'); But I'm only getting 1 arrangement, where I should have about 10. And the revenue is the total revenue of all arrangements, not for the specific arrangement. Can someone help me to fix this, please? Kind regards, Michel
[eluser]momo123[/eluser]
Be happy that you get a result ;-) Every other database than MYSQL gives an error if you try above. You have to group your columns with the group-by-function. Read this: http://dev.mysql.com/doc/refman/5.0/en/g...tions.html Good luck!
|
Welcome Guest, Not a member yet? Register Sign In |