I have sql query
select
DISTINCT {fn MONTHNAME(entrydate)} AS monthname,
emirate_name,
location,
price,
bedroom
from itf_property
where
emirate_name='Dubai'
and location='JBR'
and bedroom='2'
group by monthname
order by id
I want to select the null month also from jan to dec like if jan have no value then it will show 0.
The output of above query is attached image
Use if on mysql
select
DISTINCT {fn MONTHNAME(entrydate)} AS monthname,
emirate_name,
if(month is null, '0', month) as month,
location,
price,
bedroom
from itf_property
where
emirate_name='Dubai'
and location='JBR'
and bedroom='2'
group by monthname
order by id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.