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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -