Home > database >  Pray god give a idea...
Pray god give a idea...

Time:09-16

My side has two tables, for example, 1. The video list, 2, the history of the user to watch the video record
The next time a user enters the system, recommended to him, "he has not seen" video, tell me,,, how to get ah ~ ~ ~ ~

CodePudding user response:

Select id from a left join b on Anderson, d=b.i d where b.i d is not null

CodePudding user response:

 A watch video 
B table history record

SELECT * FROM A
WHERE A. Video ID not in (SELECT video ID FROM B)

CodePudding user response:

Select * from video v
Where not the exists (
Select 1 from view_record vr
Where vr. Video_id=v.i d and vr. User_id=# {username}
)
  • Related