select x.code,x.type,x.period,ifnull(y.amount,0) as 'amount'
from (select concat(e1.er_emergency_type,e2.er_period) as 'code'
,e1.name as 'Type',e2.name as 'Period'
from er_emergency_type e1,er_period e2
order by code) x
left join (select concat(e.er_emergency_type,e.er_period) as 'code'
,count(e.vn) as 'amount'
from er_regist e
where e.vstdate between '2009-1-1' and '2009-1-1'
group by e.er_emergency_type,e.er_period) y on x.code=y.code
แบบนี้พอได้ม่ะ