我有声明:
$statement_q = "
SELECT img
, title
, time
, videos.id
, date
FROM videos
JOIN videocategories
ON videos.id = videocategories.video_id
JOIN categories
ON categories.id = videocategories.category_id
WHERE categories.name != 'Western'
GROUP
BY videos.id
ORDER
BY videos.id
LIMIT {$startpoint} , {$per_page}";
等级制度:
如果电影有多个类别,它将显示它!
电影1:韦斯特恩,冒险(它将展示它)
电影2:西部片(一个类别,所以不会播放)
如何排除西方电影?
最佳答案
像这样的事情应该行得通。我现在无法创建表来验证它。
$statement_q = "SELECT img,title,time,videos.id as id,date FROM videos
INNER JOIN videocategories ON videos.id = videocategories.video_id
INNER JOIN categories on categories.id = videocategories.category_id
WHERE categories.name != 'Western'
AND not exists (select v.id from videocategories v where v.video_id = videos.id
and v.category_id <> videocategories.category_id)
GROUP by videos.id
ORDER BY videos.id
LIMIT {$startpoint} , {$per_page}";
关于mysql - 如何按类别排除记录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32081683/