I've 2 tables:
Teams:
|-- id -- username --|
|__ 1 __ user1 __|
|__ 2 __ user2 __|
|__ 3 __ user3 __|
Payments:
|-- id -- user_id -- amount --|
|__ 1 __ 1 __ 1000 --|
|__ 2 __ 1 __ 5000 --|
|__ 3 __ 2 __ 3000 --|
|__ 4 __ 1 __ 4500 --|
|__ 5 __ 2 __ 1000 --|
I want to get users total payments. in single query. result like this:
|-- user_id -- username -- total_payment --|
|__ 1 __ user1 __ 10500 --|
|__ 2 __ user2 __ 4000 --|
Thanks.