【mysql報錯】[Err] 1248 - Every derived table must have its own alias

當我運行一條聯合查詢的sql語句時報以下錯誤:

[Err] 1248 - Every derived table must have its own alias,大概意思是每一張派生表必需要有本身的別名。這裏加上別名便可。sql

原先sql:spa

 

select * from t_test t1 where t1.content like '%test%'
Union all
select * from (select * from t_test t2 where t2.content not like '%test%' order by t2.content asc);

 

加上別名以後:code

select * from t_test t1 where t1.content like '%test%'
Union all
select * from (select * from t_test t2 where t2.content not like '%test%' order by t2.content asc) d;

再運行一遍以後問題解決blog

相關文章
相關標籤/搜索