Im having 2 tables one with products and one favourit to keep it simple i show the relevant rows.
table poducts
id
table favourit
user_id not needed in query
product_id
What i want is find the top 10 of products wich are most common in the favourit table. I think i have to do
favourit::groupBy(product_id)
and
favourit::orderBy(ammount(sum of all product_ids), desc)
But how can i get the ammount(sum of all product_ids) to order by? Also would this query (with a groupby) be possible to be joined with the products table so i get the products in one query?