1248 - Every derived table must have its own alias

背景

在做SQL查询时运行


```sql
> select  count(*) from 
>  ( select date,hid,avg_rating 
>   from t1 
>   left join
> t2 on t1.date=t2.createdDate order by date )

`

``

报错:> 1248 - Every derived table must have its own alias

问题解决

查了下基本意思是派生出来的表需要有自己别名
于是或中间表需要加个t

select 
count(*)
from 
(
select date,hid,avg_rating 
from t1 left join t2
on t1.date=t2.createdDate
order by date )t

你可能感兴趣的:(sql,数据库,sql,mysql)