DROP PROCEDURE IF EXISTS get_artist;
CREATE PROCEDURE get_artist(IN artist_id integer(11), IN show_links integer(1))
BEGIN
SELECT * FROM artist where id = artist_id;
IF show_links=1
THEN LEFT JOIN artist_social_links ON artist_social_links.artist_id = artist_id;
END IF;
end;
CALL get_artist(196796, 1);
DROP PROCEDURE IF EXISTS get_artist;
DELIMITER ;;
CREATE PROCEDURE get_artist(IN artist_id integer(11), IN show_links integer(1))
BEGIN
CASE WHEN show_links=1
THEN
SELECT *
FROM artist
where id = artist_id;
ELSE
SELECT *
FROM artist
LEFT JOIN artist_social_links ON artist_social_links.artist_id = artist_id
where id = artist_id ;
END CASE;
END;;
DELIMITER ;
CALL get_artist(196796, 1);