I came to situation where I have to join 2 tables on some other table:
This is how I join:
domains ON some_table.domain = domains.domain
domaintypes ON domaintype.id = domains.domaintype_id
Now it happens that sometimes there is no domain for some_table row (so the domaintype will be NULL) and I want to be able to set this column default value 0 (when that happens)..
How is it possible to do that?
Many thanks in advance!
select coalesce(domain_id,0), ...
left join domains on some_table.domain = domains.domain
left join domaintypes on domaintype.id = domains.domaintype_id