I currently have this left join as part of a query:
LEFT JOIN movies t3 ON t1.movie_id = t3.movie_id AND t3.popularity = 0
The trouble is that if there are several movies with the same name and same popularity (don't ask, it just is that way :-) ) then duplicate results are returned.
All that to say, I would like to limit the result of the left join to one.
I tried this:
LEFT JOIN
(SELECT t3.movie_name FROM movies t3 WHERE t3.popularity = 0 LIMIT 1)
ON t1.movie_id = t3.movie_id AND t3.popularity = 0
The second query dies with the error:
Every derived table must have its own alias
I know what I'm asking is slightly vague since I'm not providing the full query, but is what I'm asking generally possible?
LEFT JOIN ... ON ... AND ... LEFT JOIN ...
are you? and isLIMIT 1
at the end of your statement not what you're after? – MeanwhileDISTINCT
statement, maybe that can solve your problem. – SteffaniesteffenLEFT JOIN
in the query, yes. There are two more before it. I can't just stickLIMIT 1
at the end, however, because the query as a whole returns many rows. – Buyse