USE test; DELIMITER $$ DROP PROCEDURE IF EXISTS joint_movies$$ CREATE PROCEDURE joint_movies(actor1 VARCHAR(255), actor2 VARCHAR(255)) BEGIN select concat('Movies featuring both ',actor1,' and ',actor2,':'); select concat(title,' (',year,')') from imdb.productions where type='movie' and tcode in (select p1.tcode from imdb.principals p1 , imdb.principals p2 where p1.tcode=p2.tcode and p1.ncode in (select ncode from imdb.persons where name=actor1) and p2.ncode in (select ncode from imdb.persons where name=actor2) and p1.category!='self' and p2.category!='self') order by year; END $$ DELIMITER ; call joint_movies('Owen Wilson','Luke Wilson');