SELECT a.lname, a.fname, a.user_id, c.address, c.city, c.zip, c.addresstypeid, d.descriptor as state
FROM users a, address c, maintstatetype d
WHERE a.user_id = c.user_id(+)
AND c.statetypeid = d.statetypeid(+)
AND c.addresstypeid in (1,2)
I have a database of users and addresses. Each user can have multiple addresses and the addresses are designated by addresstypeid. In plain english, what I want to pull is "If they have an addresstypeid of 2, use that, if not, use addresstypeid of 1".