SELECT CASE WHEN EXISTS (SELECT * FROM usergroupmap WHERE groupId = groupIdIn AND userId = v_friendId) THEN 'EXIST' ELSE 'NOT EXIST' END INTO flag;