0

これらの列を持つテーブルがあります:

id | series_id | season_id | episode_id |  title | type ...

series_id一意のwhereseason_idepisode_idare maxを持つ行を取得したいと思います。

4

4 に答える 4

1

1つの解決策はこれを行うことです:

SELECT t1.*
FROM YourTable AS t1
INNER JOIN 
(
   SELECT 
     series_id, 
     MAX(season_id)  AS MAxSeasonId, 
     MAX(Episode_id) AS MAXEpisodeID
   FROM yourTable 
   GROUP BY series_id
) AS t2  ON t1.series_id  = t2.series_id
        AND t1.season_id  = t2.MaxSeasonId
        AND t1.episode_id = t2.MaxEpisode_id;
于 2013-02-10T09:28:08.263 に答える
0
SELECT *
FROM TableName t1
WHERE EXISTS (
              SELECT 1
              FROM t2
              WHERE t1.series_id = t2.series_id
              HAVING MAX(t2.season_id) = t1.season_id
                AND MAX(t2.episode_id ) = t1.episode_id
              )
于 2013-02-10T11:10:09.110 に答える
0

これを試して..

SELECT * FROM TABLE
HAVING MAX(season_id) AND MAX(episode_id)
GROUP BY series_id

:)

于 2013-02-11T02:17:17.220 に答える