sql - Display all fields regardless if total is zero -


i have 4 tables:

  • requestpossibility fields id, requestid, text
  • requestcategory fields text, requestid
  • requestoutcome fields id, requestid
  • request field requestid

here query returns results when "total" not 0. want return results type "text". here query:

select                 max(rc.text) text,                 max(rp.text) textpossibility,                 count(*) total request r                 join requestoutcome ro on r.requestid = ro.id                 join requestpossibility rp on ro.id = rp.id                 join requestcategory rc on rp.requestid = rc.requestid group rp.id order 1, 2 asc 

if count specific field , use left join might resolve this.

 select             max(rc.text) text,             max(rp.text) textpossibility,             count(r.requestid) total request r             left join requestoutcome ro on r.requestid = ro.id             join requestpossibility rp on ro.id = rp.id             join requestcategory rc on rp.requestid = rc.requestid group rp.id order 1, 2 asc 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -