gpt4 book ai didi

mysql - SQL错误 "Every derived table must have its own alias"

转载 作者:行者123 更新时间:2023-11-29 10:33:37 24 4
gpt4 key购买 nike

这是我的 SQL 查询。

SELECT MAX(course_id), sec_id, COUNT(ID) 
FROM (SELECT MAX(course_id), sec_id, COUNT(ID)
FROM section
NATURAL JOIN takes
GROUP BY course_id);

执行时,我收到此错误:

<"Every derived table must have its own alias">

最佳答案

向派生表添加别名。

SELECT 
MAX(course_id),
sec_id,
COUNT(ID)
FROM
(
SELECT
MAX(course_id),
sec_id,
COUNT(ID)
FROM
section NATURAL
JOIN takes
GROUP BY
course_id
) `A`;

关于mysql - SQL错误 "Every derived table must have its own alias",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46916681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com