2020-04-08, 12:24
(2020-04-08, 11:37)TheGeekSteve Wrote: 1. Movies with only a German audio streamI'm not shure if that is the best/fastest way to query, but it works. Maybe an SQL expert know a better way to solve it. This query does:
- get a list of all "MovieID" that have more than one entry (stream) in the MoviesAStreams
- use that ID list to filter the full "movielist" by movies with an ID that's in that ID list and also have the audio language "deu" or "ger"
sql:SELECT DISTINCT *
FROM
movielist
LEFT OUTER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
WHERE idMovie IN (
SELECT idMovie
FROM
movielist
INNER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
GROUP BY
movielist.idMovie
HAVING
COUNT(MoviesAStreams.StreamID) = 1) AND
(MoviesAStreams.Audio_Language = 'deu' OR MoviesAStreams.Audio_Language = 'ger')
(2020-04-08, 11:37)TheGeekSteve Wrote: 2. Movies with a German AND a English (or any other language) audio streamSame syntax but with more than one stream (COUNT(MoviesAStreams.StreamID) > 1):
sql:SELECT DISTINCT *
FROM
movielist
INNER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
WHERE idMovie IN (
SELECT idMovie
FROM
movielist
LEFT OUTER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
GROUP BY
movielist.idMovie
HAVING
COUNT(MoviesAStreams.StreamID) > 1) AND
(MoviesAStreams.Audio_Language = 'deu' OR MoviesAStreams.Audio_Language = 'ger')
(2020-04-08, 11:37)TheGeekSteve Wrote: 3. Movies with only 1 audio stream
sql:SELECT DISTINCT *
FROM
movielist
LEFT OUTER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
GROUP BY
movielist.idMovie
HAVING
COUNT(MoviesAStreams.StreamID) = 1
(2020-04-08, 11:37)TheGeekSteve Wrote: 4. Movies with more than 1 audio stream
sql:SELECT DISTINCT *
FROM
movielist
LEFT OUTER JOIN MoviesAStreams ON (movielist.idMovie = MoviesAStreams.MovieID)
GROUP BY
movielist.idMovie
HAVING
COUNT(MoviesAStreams.StreamID) > 1