How can I return a null or empty string if a key value does not exist?

IFMISSING should be what you need; something like:

SELECT name.fname AS f_name,
 name.mname AS m_name,
 name.lname AS l_name,
 IFMISSING(title,"") AS title,
 IFMISSING(suffix,"") AS suffix,
 username AS user_name,
  _id AS guid,
  security.ADMIN AS ADMIN,
  security.developer AS developer,
  security.locked AS locked,
  IFMISSING(history.created_on,NULL) AS created_on,
  IFMISSING(history.updated_on,NULL) AS updated_on
  FROM Contacts
  WHERE _type = 'user'
  AND _id = $1

HTH.

1 Like