我有两列(film_id,actor_id),我需要找到一对演员,这些演员在电影中共同出现的次数最多,例如演员10和演员20都有两部电影在一起(1,3),所以我需要返回10,20
答案 0 :(得分:0)
您可以将group_concat()
与group by
一起使用
select group_concat(actor_id) as multistarter
from movies
group by movie_id;
答案 1 :(得分:0)
不确定这是否是您想要的,但请尝试一下:
select
group_concat(actor_id) as actors
from (
select actor_id, group_concat(movie_id order by movie_id) as movies
from tbl1
group by actor_id) t1
group by movies
having count(actor_id) = 2