POSTGRESQL return records in related table even if there is no related record
Posted on 2014-03-10
What is the SELECT syntax in POSGRESQL to retrieve the all of the records from table A which has a STATE_ID field related to a STATES table having the STATE_ID and a STATE_CODE field when some of the records in table A don't have a NULL value in STATE_ID.
Ideally, I'd like to have a value such as "Unspecified" returned in lieu of the STATE_CODE when it is not present.
select id as shipid,name as shipto,city as shipcity, state_id, states.state_code from res_partner A, states where state_id = states.state.id