Limiting a left join to returning one result?

前端 未结 5 1332
野性不改
野性不改 2021-02-19 21:29

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

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-19 21:55

    LEFT JOIN movies as m ON m.id = (
        SELECT id FROM movies mm WHERE mm.movie_id = t1.movie_id
        ORDER BY mm.id DESC
        LIMIT 1    
    )
    

提交回复
热议问题