I have several tables:
videos
- id
- ch_id
- title
- date_published
channels
- id
- title
tags
- id
- title
video_tags
- v_id
- t_id
Using those tables, I am trying to select videos related to another video using tags. In my current attempt, I've tried the following:
SELECT v.id v_id, ch.id ch_id, ch.title ch_title,
v.title v_title, v.date_published v_date_published
FROM videos v
JOIN channels ch ON ch.id = v.ch_id
JOIN video_tags vt ON vt.v_id = v.id
WHERE v.id NOT LIKE 'example_id'
AND (((vt.t_id = 1) + (vt.t_id = 2) + (vt.t_id = 3) + (vt.t_id = 4)) >= 2)
GROUP BY v.id ORDER BY v.date_published LIMIT 10;
However, this does not work. I do not get errors, but I get 0 results back when I know there should be more results.
I've spent hours thinking about it and looking for answers online. Maybe I'm using the wrong words in my searches, but I haven't been able to find a solution. Any help would be greatly appreciated.
vto the tablevideos-- and so on .. These "should" be included in your SELECT -- IESELECT v.v_id, ch.ch_idetc etc