I created a view to continue to use it without having to write this piece of code every time I look under the name “Data.”
The first SQL statement will provide me with the maximum season for each series for a specific user.
SELECT s_imdbID, MAX(ep_season) FROM Data
WHERE u_ID = 1
GROUP BY s_imdbID
The second SQL statement will get the maximum episode of the last season for certain episodes for a specific user.
SELECT s_imdbID, ep_season, MAX(ep_episode) FROM Data
WHERE ep_season = (
SELECT MAX(ep_season)
FROM Data
WHERE u_ID = 1
AND s_imdbID = "tt4158110"
)
AND s_imdbID = "tt4158110"
AND u_ID = 1;
How can I integrate both of them into one SQL statement to get the following
seriesID | Max_Season | Max_Episode
-----------| ------------------| -----------
Value.... | Value............ | Value
this is the presentation code in the code that you can find out about what data will be extracted from it
SELECT
e.title AS "ep_title",
e.year AS "ep_year",
e.rated AS "ep_rated",
e.released AS "ep_released",
e.season AS "ep_season",
e.episode AS "ep_episode",
e.runtime AS "ep_runtime",
e.genre AS "ep_genre",
e.director AS "ep_director",
e.writer AS "ep_writer",
e.actors AS "ep_actors",
e.plot AS "ep_plot",
e.language AS "ep_language",
e.country AS "ep_country",
e.awards AS "ep_awards",
e.poster AS "ep_poster",
e.metascore AS "ep_metascore",
e.imdbRating AS "ep_imdbRating",
e.imdbVotes AS "ep_imdbVotes",
e.imdbID AS "ep_imdbID",
s.title AS "s_title",
s.year AS "s_year",
s.rated AS "s_rated",
s.released AS "s_released",
s.runtime AS "s_runtime",
s.genre AS "s_genre",
s.director AS "s_director",
s.writer AS "s_writer",
s.actors AS "s_actors",
s.plot AS "s_plot",
s.language AS "s_language",
s.country AS "s_country",
s.awards AS "s_awards",
s.poster AS "s_poster",
s.metascore AS "s_metascore",
s.imdbRating AS "s_imdbRating",
s.imdbVotes AS "s_imdbVotes",
s.imdbID AS "s_imdbID",
u.ID AS "u_ID"
FROM test w
INNER JOIN users u
ON u.ID = w.userid
INNER JOIN episode e
ON w.epid = e.imdbID
INNER JOIN series s
ON e.seriesID = s.imdbID
WHERE e.seriesID IN (SELECT (imdbID) FROM series);
1:
, ,
, ,