mysql - How to know count data and show in multiple table -
i have problem query.
this first table, "order":
id_order id_event ------------------ 1 12 2 12
this second table, "event_table":
id_event event_name id_eo -------------------------------- 12 festival 1 13 music 1
all want result this:
festival : 2 order music : 0 order
this have been done far:
select (select count(*) order) jumorder, event_name order p inner join event on (p.id_event = event.id_event) event.id_eo = '1'
using left join
, concat
can expected result mentioned in post.
select concat(e.event_name, ": ", count(o.id_event), " order") result `event_table` e left join `order` o on o.id_event = e.id_event id_eo = '1' group e.event_name;
result
festival: 2 order music: 0 order
sql fiddle: http://sqlfiddle.com/#!9/006c09/4
Comments
Post a Comment