Hi, I need to grab the total number of videos for each category where date_added is < today. Each video can be in multiple categories. Video id title description date_added Video_Categories id video_id category_id What's the best way to join these tables to get what i'm looking for? Thanks
hi... from your tables structure... i guess that Video.id is related to Video_Categories.id... if that's true may be you can try this query select vc.category_id, count(*) as tot_number from Video_Categories vc, Video v where v.id = vc.id and date_added < 'yyyy-mm-dd' group by category_id thank's....
hmm.. not sure if you really need to join the videos table.. just adds to the turnaround time. you could simply try select categories_id, count(video_id) as vid_count from video_categories group by categories_id I think that will do the trick. Cheers.
Thanks for the reply guys, Cahya77, that worked. Did some testing on a lot of entries and it seemed to be pretty fast. I needed to join the tables since I need to account for the date.