I have 2 tables users, and products_users.
I want to get all users where their FBID as in a predetermined list…HOWEVER i also want to get the total count of how many times they appear in the products_users table… (this essentially shows how many different products a user “liked” on my site)
In the end I would want:
user1, 4
user2, 7
user3, 28
etc.
The issue is getting the count to work.
I have this currently:
select users.*
, products_users.fbid
, products_users.`graph_id` as objects_liked
from users
inner join products_users
on (products_users.`fbid` = users.fbid)
and products_users.`fbid` in ('0_fbid','1_fbid')
which results in the following:

However, instead I want each row to be a unique user and the objects_liked column to represent to TOTAL count.
Is there a way to do this? Please help!
FYI – I have already tried to change
products_users.`graph_id` as objects_liked
to
count(products_users.`graph_id`) as objects_liked
but that only results to:

Please help!
I find it a bit confusing how you are expecting to get
user1, 4 user2, 7 user3, 28 etc.as a result and you’re selecting byusers.*, products_users.fbid, products_users.graph_id. I assume the first result is the one you’re expecting to get.The following query will show you the users and the amount of times they appear in the products_users table (I understand that is what you’re looking for). I’m guessing the
userscolumns because you didn’t provide them.Hope that helps.