比如我這邊有兩張表,1.視頻表,2,用戶觀看視頻的歷史記錄表
當下次用戶進入系統時,向他推薦“他未看過的”視頻,請問。。。該怎么弄呀~~~~
uj5u.com熱心網友回復:
select id from a left join b on a.id =b.id where b.id is not nulluj5u.com熱心網友回復:
A表 視頻表
B表 歷史記錄表
SELECT * FROM A
WHERE A.視頻ID not in (SELECT 視頻ID FROM B)
uj5u.com熱心網友回復:
select * from video vwhere not exists (
select 1 from view_record vr
where vr.video_id = v.id and vr.user_id = #{userId}
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/7132.html
標籤:MySQL
