SELECT uid, summary, facebook, twitter, blog, website, CASE WHEN dname IS null OR dname = "" THEN fullname ELSE dname END AS fullUserName FROM johnhunt_jhp.relationships r INNER JOIN johnhunt_jhp.user_profiles u ON r.rTarget=u.uid INNER JOIN `johnhunt_modx`.`web_user_attributes` wa ON wa.internalkey=u.uid INNER JOIN johnhunt_jhp.books b ON r.rSource=b.bID WHERE r.rFilter=3 AND r.rType="user" AND u.aURLSlug="authors"