select case when count(*) = 0 then 1 else 0 end from ab_contacts_related where contact_id = :contact_id select case when count(*) = 0 then 0 else 1 end from acs_objects where object_id = :contact_id and object_type = 'ab_contact'