postgresql7.1 select case when count(*) = 0 then 0 else 1 end where exists (select 1 from category_object_map where category_id = :id)