SQL case statement not executing else part
This returns the wanted result, but i don't think that you wnat only the course id.

But this should help further

DELIMITER $$
CREATE FUNCTION search(roll_num VARCHAR(50))
RETURNS VARCHAR(150)
DETERMINISTIC
BEGIN
    IF (EXISTS(SELECT 1 FROM `student` WHERE `student`.`roll_no` = roll_num)) THEN
        RETURN (SELECT CONCAT (`student`.`student_name`,`student`.`course_id`) FROM `student`WHERE `student`.`roll_no` = roll_num);
    ELSE
        RETURN 'Roll No not exist ';
    END IF;
END$$
DELIMITER ;