Limiting a left join to returning one result?

前端 未结 5 1268
野性不改
野性不改 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 22:00

    MySQL 5.7+ allows you to use ANY_VALUE. you didn't provide the full query so i'll have to guess using xxx

    SELECT xxx.id,ANY_VALUE(m.movie_name) movie_name, ANY_VALUE(popularity) popularity
    FROM xxx
    LEFT JOIN movies m ON (m.movie_name=xxx.movie_name AND popularity=0)
    GROUP BY xxx.id
    

    more info https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

提交回复
热议问题