sqlite - SQL missing 0 values -


i have problem 1 query:

select first_name, last_name, count(scheduleevents.id)  workers join scheduleevents  on scheduleevents.worker_id = workers.id 

this query result is: workers have events ( more 0) in scheduleevents table want workers 0 events too. left join don`t work , ifnull option how can resolve problem?

you can use left join, you're missing group result per worker;

select first_name, last_name, count(scheduleevents.worker_id)  workers left join scheduleevents    on scheduleevents.worker_id = workers.id group workers.id; 

an sqlfiddle test with.


Comments

Popular posts from this blog

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -