#案例:根據女神名,查詢對應的男神信息ide
DELIMITER $ CREATE PROCEDURE myp2(IN beautyName VARCHAR(20)) BEGIN SELECT bo.* FROM boys bo RIGHT JOIN beauty b #採用外鏈接是由於內鏈接無沒有男神的女神信息 ON bo.id=b.boyfriend_id WHERE b.name=beautyName; END $
#調用
CALL myp2('小昭')$code
#用戶是否登陸成功(多個in模式),看是否打印個數來判斷是否登陸成功it
CREATE PROCEDURE myp4(IN username VARCHAR(20),IN PASSWORD VARCHAR(20)) BEGIN DECLARE result INT DEFAULT 0; SELECT COUNT(*) INTO result FROM admin WHERE admin.username=username AND admin.password=PASSWORD; SELECT IF(result>0,'成功','失敗'); END $
#調用class
CALL myp4('張飛','8888')$