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
Post a Comment