I have an app which allows users to vote and have two tables
Video
|id|uri_code|filename|created_on|deleted|
Votes
|id|video_id|ip|created_on|
I’d like to be able to select all the video information and have the total number of votes for each video, is this possible with an sql statement or would I be best off doing it with the server side code?
It’s certainly possible with SQL – this sort of thing is exactly what SQL is great at! You want to “group” a count of all votes by video, so the
GROUP BYclause is exactly what you’re after: