mysql - joining a SQL table with no value -


i doing table join

select b.type business,         b.business business,        b.city city  businesses b     join cities c on n.city = c.id; 

my problem table looks this:

id    type   business    city  1     1       2           4  2     4       5           2  3     2       3           0 

so rows have value of city 0. however, table join if city=0, id 3 not shown in results. there no city id of 0. there way rectify using sql?

as eggyal suggested, query this:

select b.type business,         b.business business,        case when c.city  null 'n/a' else c.city end city  businesses b    left join cities c on b.city = c.id; 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -