我想检索数据表格 3 即指定表格
- UserDetail(Fname,Lname,User_id),
- 电影(Movie_id,MovieName)
- UserLikedMovies(User_id,Movie_id)
这样当用户输入特定的 Movie_id 时,用户 ID Fname Lname 从电影中输入用户详细信息 MovieName,这是我尝试过的
SELECT UserDetail.FName
FROM
UserDetail UserDetail
INNER JOIN
UserLikedMovies UserLikedMovies
ON
UserDetail.User_id = UserLikedMovies.User_id
INNER JOIN
(
SELECT
Movies.MovieName,
Movies.Movie_id
FROM
Movies Movies
INNER JOIN
UserLikedMovies UserLikedMovies
ON
Movies.Movie_id = UserLikedMovies.Movie_id
INNER JOIN
UserDetail UserDetail
ON
UserLikedMovies.User_id = UserDetail.User_id
WHERE
Movies.Movie_id IN ( Select UserLikedMovies.Movie_id from UserLikedMovies where UserLikedMovies.Movie_id = 4)
) as ABC
ON UserLikedMovies.Movie_id = ABC.Movie_id
AND Movies.Movie_id = ABC.Movie_id