Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Bestellen Sie nach Feld in MYSQL

wie wäre es damit:

select a.col as type,coalesce (`COUNT`,0) as `count`
from 
(select 'A' as col union all
select 'B' as col union all
select 'C' as col union all
select 'D' as col )a
left join Table1 T
on a.col=T.type
order by FIELD(a.col,'A','B','C','D') ; 


SQL-Fiddle-Demo