mysql join count -



mysql join count -

i have 2 table

table leave

id | type 1 annual 2 sick 3 unpaid 4 marriage

table leavedata

idleavedata | leavetype* 1 1 2 1 3 2 4 2

leavetype foreign key (refer id in table leave)

how count occurence of id in table leavedata?

output illustration :

type | count annual 2 sick 2 unpaid 0 or null marriage 0 or null

try,

select l.type , count(ld.leavetype) count leave l left bring together leavedata ld on ld.leavetype = l.id grouping ld.leavetype

mysql

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -