SELECT
  u.id,
  u.display_name,
  ue.email
FROM users u LEFT OUTER JOIN user_emails ue ON ue.user_id = u.id AND ue.primary
WHERE u.id = $(userId);