【发布时间】:2020-10-03 11:46:57
【问题描述】:
你好,下面是我的代码
数据库:https://dev.mysql.com/doc/sakila/en/sakila-structure.html
select concat(first_name,' ',last_name) from
customer where customer_id in (
select customer_id from (
select customer_id, count(rental_id) as num
from
category
inner join film_category using(category_id)
inner join film using(film_id)
inner join inventory using(film_id)
inner join rental using (inventory_id)
where name='Sci-Fi'
group by customer_id, rental_id)
where num > 5)T)
当我执行时,我收到以下错误
ERROR 1248 (42000) at line 2: Every derived table must have its own alias
预期结果是"full names of customers who have rented sci-fi movies more than 5 times. Arrange these names in the alphabetical order"
你能告诉我我做错了什么吗?
【问题讨论】:
-
请use text, not images/links, for text--including tables & ERDs。转述或引用其他文本。只提供您需要的东西并将其与您的问题联系起来。仅将图像用于无法表达为文本或增强文本的内容。无法搜索或剪切和粘贴图像。在图像中包含图例/键和说明。此外,链接死了。使用编辑功能插入图像/链接。让您的帖子自成一体。
-
请在代码问题中给出minimal reproducible example--cut & paste & runnable code,包括最小的代表性示例输入作为代码;期望和实际输出(包括逐字错误消息);标签和版本;明确的规范和解释。给出尽可能少的代码,即您显示的代码可以通过您显示的代码扩展为不正常的代码。 (调试基础。)对于包含 DBMS 和 DDL(包括约束和索引)和输入为格式化为表的代码的 SQL。 How to Ask 暂停整体目标的工作,将代码砍到第一个表达式,没有给出你期望的内容,说出你期望的内容和原因。
标签: mysql sql join select group-by