gpt4 book ai didi

mysql - 对使用别名失败的派生表执行 LEFT Join

转载 作者:行者123 更新时间:2023-11-29 01:30:20 27 4
gpt4 key购买 nike

<分区>

SQL 新手。我正在尝试对两个派生表执行 LEFT JOIN,但出现错误 Every Derived Table must have an alias. 我确实为它们提供了别名,但它仍然给出相同的错误消息。以下是查询:

SELECT * FROM 
(SELECT first_name
from users
inner join messages
on (users.id=messages.from_user_id)
where to_user_id=1
group by first_name order by message_date) AS DATAONE
LEFT JOIN
(select * from
(SELECT count(message_id),u.id,first_name,message_subject,message_status
from users u
inner join messages m
on (u.id=from_user_id)
where to_user_id=1 and message_status = 2
group by first_name order by message_date) as datatwo)
on (dataone.first_name = datatwo.first_name)

请指教。

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