I have a table Named ProductLike with the fields ProductId, UserId, and Like. When a user likes a product, a record is added to this table with the UserId and ProductId, as well as the Like value (true or false). I want to get a list or group of users who have each product. This is what I have tried so far, but it has errors.
SELECT p.UserId,*
FROM ProductLike p WHERE p.ProductId =
(SELECT pk.ProductId FROM ProductLike pk WHERE pk.ProductLike = 1);
You can alias the table and join like so:
This will give you a result set of all users who have “liked” the same product.
EDIT: If you wanted to get a result set of all products that have been liked more than once, you could do this: