【发布时间】:2009-11-20 18:04:34
【问题描述】:
我正在使用 MySQL。
我有以下表结构:表名:视频
videoId title description
1 Video title 1 Some description text1
2 Video title 2 Some description text2
3 Video title 3 Some description text3
4 Video title 4 Some description text4
5 Video title 5 Some description text5
然后我有一张桌子:WatchedVideos
id videoId Userid date
1 2 234 2009-11-12 04:46:44
2 2 212 2009-11-13 04:46:44
3 3 234 2009-11-13 05:46:44
4 4 235 2009-11-13 06:46:44
5 4 235 2009-11-13 07:46:44
6 1 234 2009-11-13 08:46:44
7 1 234 2009-11-13 09:46:44
现在我想获取“正在观看的视频”是指最近被不同用户观看的最新 2 个(我会根据我的情况修改)视频的列表,但是当我在上述两个之间申请加入时表格然后它给出了我不想要的重复游戏,如果一个用户观看了两次相同的视频,那么它给出了两次该视频,我想要唯一的视频详细信息列表如下:
videoId title description
1 Video title 1 Some description text1
4 Video title 4 Some description text4
请告诉我应该进行什么类型的查询来获取这些数据?
谢谢
【问题讨论】: