I have two tables in my database with the following schemas:
ratings table:
usedId
movieId
rating
info table
movieId
imdbId
The movieId values in each table are the same (ie movieId 1 is the same movie in both).
Each movieId & userId appears multiple times in the ratings table.
What I am trying to do is create a new table that looks like:
new table:
userID
movieId
imdbId
rating
Where the imdbId is added for each row that matches the movieId of its original table.
select ratings.userID, ratings.movieId, info.imdbId, ratings.rating from
ratings inner join info on ratings.movieId = info.movieId
Or you can manual join the two tables:
SELECT r.userID, r.movieId, i.imdbId, r.rating
FROM ratings r, info i
WHERE r.movieId = i.movieId
You should use SQL Join
to create your expected table.
select Rating.userID, Rating.movieId, Info.imdbId, Rating.rating
from ratings as Rating
inner join
info as Info on ratings.movieId = info.movieId
To get more details of join check this inner join link
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.