SELECT returning data that was not seen by a certain user

5

I'm having a hard time putting together Query

I have 2 tables:

  • video_visualizacoes with fields visualizacao_id, video_id, conta_id (This field refers to the user who viewed the video) ".
  • videos with fields video_id, video_titulo e conta_id (This field refers to uploader of video) "

I need a Query to return all videos that have not yet been viewed by a particular user.

    
asked by anonymous 15.01.2016 / 20:01

2 answers

3

The following way you will get

select v.* from videos v
where v.video_id not in (select t.video_id video_visualizacoes t where t.conta_id=v.conta_id)
and v.conta_id= id
    
15.01.2016 / 20:22
0

You've tried something like this:

SELECT videos.video_id
FROM videos 
JOIN video_visualizacoes ON videos.conta_id <> video_visualizacoes.conta_id 
ORDER BY videos.video_id DESC
    
15.01.2016 / 20:22