My code is:
$vote = DB::SELECT(DB::RAW("SELECT * FROM votes WHERE product_id = product_id; "));
Here[1] is a screenshot of my DB.
I'd like to ask how to select the same Producut Id in the SQL Query?
My code is:
$vote = DB::SELECT(DB::RAW("SELECT * FROM votes WHERE product_id = product_id; "));
Here[1] is a screenshot of my DB.
I'd like to ask how to select the same Producut Id in the SQL Query?
If you want to count sum of votes for each product and sort sum of votes from highest to lowest, then your query is:
SELECT
product_id, SUM(vote) as `vote_rate`
FROM
votes
GROUP BY
product_id
ORDER BY
`vote_rate` DESC