Buddypress get data from wp_bp_groups_members table [closed]

Simpler solution:

function get_relationship($group_id,$user_id) {
    global $wpdb;
    $relationships = $wpdb->get_col("SELECT relationship FROM wp_bp_groups_members WHERE group_id = $group_id AND user_id = $user_id");
    if ( !empty( $relationships ) ) {
        foreach ( $relationships as $relationship ) {
            return $relationship;
        }
    }
}

And it should go in plugins/bp-custom.php or your-theme/functions.php.
Not bp-groups-template.php, which is a core file and should not be hacked.