SELECT videos.id, videos.game_id, videos.xbox360, videos.ps3, videos.pc,
videos.wii, videos.other, videos.thumbnail, videos.vid_info, videos.sdvid,
videos.hdvid, UNIX_TIMESTAMP( videos.date_added ) , game_data.name,
AVG( video_ratings.rating )
FROM videos, game_data, video_ratings
WHERE videos.game_id = game_data.id
AND videos.id = video_ratings.video_id
GROUP BY videos.id, video_ratings.video_id
ORDER BY videos.date_added DESC LIMIT 10;
我正在运行此查询以从三个表中提取数据video_ratings
,game_data
视频...
现在我面临的问题是结果仅显示已评级(或在表格中video_ratings
)的视频,因为AND videos.id = video_ratings.video_id
......
有什么方法可以选择所有视频的数据,如果表格AVG(video_ratings.rating)
中不存在这些视频的评级,结果显示为空video_ratings
(或者说没有视频被评级,因此结果必须显示 10 行,AVG(video_ratings.rating)
列为空值 ) ...
谢谢