using DISTINCT with merged tables?
am 02.04.2006 05:39:57 von goomba
i need to combine two tables, then retrieve unique results. this works, but
it is also outputting all the movie_ids in mMovies as well, which results in
duplicates. i only want one. how can i make this work? Thanks!!
SELECT DISTINCT mMovies_Genres.movie_id, title_the, title, season, genre_id
FROM mMovies, mMovies_Genres
WHERE mMovies.movie_id = mMovies_Genres.movie_id
AND bonusDisc is null
Re: using DISTINCT with merged tables?
am 02.04.2006 07:02:17 von Shion
Goomba wrote:
> i need to combine two tables, then retrieve unique results. this works, but
> it is also outputting all the movie_ids in mMovies as well, which results in
> duplicates. i only want one. how can i make this work? Thanks!!
>
> SELECT DISTINCT mMovies_Genres.movie_id, title_the, title, season, genre_id
> FROM mMovies, mMovies_Genres
> WHERE mMovies.movie_id = mMovies_Genres.movie_id
> AND bonusDisc is null
>
>
drop the mMovies_Genres.movie_id as all the entries (should at least be)
unique or you will get all. If you need to get this value too, then use GROUP
BY instead of DISTINCT.
//Aho