I have a Users
Table
it has id, username, A
, and B
as my columns.
I also have a Votes
Table.
a user can vote on A
, and B
.
it has id, user_id foreign key, A_id foreign key, and B_id foreign key.
I would like to do a query to Users and have the tally of votes for A
and votes for B
included.
so lets say I find a User with the id of 1,
How would I get something like
{
"id": 1,
"display_name": "test",
"A" : 32,
"B" : 132
}
Assuming there are 32 rows in the Votes table and 132 rows for B in the Votes table.