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

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -