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)
请指教。