我试图用 SQL 编写以下要求:
每个用户都可以根据自己的喜好对电影进行评分。(1=我不喜欢,5=我喜欢它)并且系统应该向当前用户提供他尚未评分但其他用户也喜欢的电影列表。
为简化起见,我有这张表和以下数据:
create table wich (
uid int,
film varchar(50),
rate int
);
insert into wich values
(1, 'usual suspect', 5), (1, 'gataca', 4), (1, 'goldeneye', 2),
(2, 'usual suspect', 4), (2, 'gataca', 5), (2, 'i am a legend', 4), (2, 'the hobbit', 1),
(3, 'usual suspect', 1), (3, 'gataca', 5), (3, 'goldeneye', 5),
(4, 'usual suspect', 5), (4, 'goldeneye', 5),
(5, 'usual suspect', 5), (5, 'gataca', 4), (5, 'goldeneye', 5),
(6, 'usual suspect', 4), (6, 'gataca', …
Run Code Online (Sandbox Code Playgroud)