#案例:根据女神名,查询对应的男神信息

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('小昭')$

#用户是否登录成功(多个in模式),看是否打印个数来判断是否登录成功

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 $

#调用

CALL myp4('张飞','8888')$