我有以下疑问
SELECT * FROM(
(select * from `responses` a order by id, exam, question)
left JOIN
(select max(exam) as maxexam from responses b )
on a.exam <= b.maxexam
and id > 2) c
我收到以下错误消息
Every derived table must have its own alias
如果您使用连接条件
on a.exam <= b.maxexam and id > 2
,那么您需要为两个子查询提供别名a
和b
:
SELECT * FROM
/* alias a applied to first subquery: */
(select * from `responses` order by id, exam, question) a
left JOIN
/* alias b applied to second subquery: */
(select max(exam) as maxexam from responses) b
on a.exam <= b.maxexam and id > 2
;