【发布时间】:2020-03-29 21:12:32
【问题描述】:
给定 3 张桌子。我需要构建 SQL 查询来找到两个演员一起最多的演员并列出标题 那些电影。按字母排序
https://www.db-fiddle.com/f/r2Y9CpH8n7MHTeBaqEHe9S/0
表film_actor
Column | Type | Modifiers
------------+-----------------------------+----------
actor_id | smallint | not null
film_id | smallint | not null
... 表演员
Column | Type | Modifiers
------------+-----------------------------+----------
actor_id | integer | not null
first_name | character varying(45) | not null
last_name | character varying(45) | not null
... 桌膜
Column | Type | Modifiers
------------+-----------------------------+----------
film_id | integer | not null
title | character varying(255) | not null
... 所需的输出:
first_actor | second_actor | title
------------+--------------+--------------------
John Doe | Jane Doe | The Best Movie Ever
...
【问题讨论】:
-
示例表数据和预期结果会有所帮助。 minimal reproducible example
-
@jarlh 你能解释一下我需要添加什么吗?我在帖子底部提供了预期的结果
-
是,但缺少匹配的样本数据。 (通常每张表几行就可以了。)
-
@jarlh 如何添加它?
-
@jarlh 找到了方法db-fiddle.com/f/r2Y9CpH8n7MHTeBaqEHe9S/0
标签: sql