从多个表中返回什么都没有加入mysql - 三个表

时间:2013-06-14 11:30:32

标签: php mysql sql

我编写了下面的sql查询来获取当前用户IP看不到的一个视频。但我总是没有视频。这是我的代码

SELECT views_videos.Vid_URL,views_videos.Vid_Owner,views_videos.Vid_Points,
views_videos.Vid_ID
FROM members
    JOIN views_videos
        ON members.member_id=views_videos.Vid_Owner
    JOIN videoed_video
        ON views_videos.Vid_ID = videoed_video.VID_ID
  where 
  views_videos.IsEnable='yes' AND members.points > 15 
AND members.account_stat = 'active'  
AND views_videos.Vid_Limit >= views_videos.views_sovar 
AND views_videos.Vid_Daily >= views_videos.today_view 
AND videoed_video.view_Date NOT BETWEEN '$yesterDayTimeStamo' AND '$todayTimestamp'
AND videoed_video.view_IP != '$ip'
order by views_videos.Vid_Points DESC,rand() limit 1

我多次重写代码,我花了一个月的时间来尝试解决这个问题。在上面的查询中,我加入了3个表,然后尝试应用一些条件来获取当前用户IP看不到的视频,但是我从查询中找不到任何东西。

0 个答案:

没有答案