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

When I run a sql statement Times union query the following error:

[Err] 1248 - Every derived table must have its own alias, probably meaning that each one derived table must have its own alias. Here you can add an alias.

Original sql:

 

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);

 

After adding Alias:

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;

Then run it again after the problem is solved

 

Guess you like

Origin www.cnblogs.com/HeiDi-BoKe/p/11763494.html