我想获取与当前正在播放的视频相关的所有视频,即获取当前视频用户的所有视频或获取当前视频类别的所有视频或获取当前视频标签的所有视频,我尝试过以下两个查询结构但我在这两种情况下只得到一条记录,查询中的23条是当前的视频ID。任何帮助将不胜感激。
我有以下表{fields}
QUERY 1:。
SELECT v.title, v.duration,v.url ,v.date,u.uname, count(distinct l.id) AS likes,count(distinct vt.vid) AS views
FROM videos_table AS v
JOIN users_table AS u ON u.uid=v.uid
JOIN likes_table AS l ON l.vid=v.vid
JOIN views_table AS vt ON vt.vid=v.vid
JOIN categories_table AS c ON c.vid=v.vid
JOIN tags_table AS t ON t.vid=v.vid
WHERE u.uid=(SELECT uid FROM videos_table WHERE vid=23) OR
c.cid IN ( SELECT GROUP_CONCAT(DISTINCT cid) from categories_table WHERE c.vid=23 ) OR
t.tid IN ( SELECT GROUP_CONCAT(DISTINCT tid) FROM tags_table WHERE vid=23 )
QUERY 2:。
SELECT v.title, v.duration,v.url ,v.date,u.name, count(distinct l.id) AS likes,count(distinct vt.vid) AS views
FROM videos_table AS v, users_table AS u,likes_table AS l,views_table AS vt ,categories_table AS c,tags_table AS t
WHERE (u.uid=v.uid AND l.vid=v.vid AND c.vid=v.vid AND vt.vid=v.vid)
AND
(u.uid=(SELECT uid from videos_table WHERE vid=23) OR
c.cid IN (SELECT GROUP_CONCAT(DISTINCT cid) FROM categories_table WHERE vid=23) OR
vt.tid IN (SELECT GROUP_CONCAT(DISTINCT tid) FROM tags_table WHERE vid=23))