mysql out模式的存储过程
作者:互联网
#案例:根据女神名,返回对应的男神名
DELIMITER $
CREATE PROCEDURE myp5(IN beautyName VARCHAR(20),OUT boyName VARCHAR(20))
BEGIN
SELECT bo.boyName INTO boyName
FROM boys bo
INNER JOIN beauty b ON bo.id=b.boyfriend_id
WHERE b.name=beautyName;
END $
#调用
SET @bName $
CALL myp5('小昭',@bName) $
SELECT @bName $
或
CALL myp5('小昭',@bName)$
SELECT @bName$
#案例:根据女神名,返回对应的男神名和男神魅力值
CREATE PROCEDURE myp6(IN beautyName VARCHAR(20),OUT boyName VARCHAR(20),OUT userCp INT)
BEGIN
SELECT bo.boyName ,bo.userCp INTO boyName,userCP
FROM boys bo
INNER JOIN beauty b ON bo.id=b.boyfriend_id
WHERE b.name=beautyName;
END $
#调用
CALL myp6('小昭',@bName,@usercp)$
SELECT @bName,@usercp$
标签:存储,beautyName,bo,boyName,bName,mysql,id,SELECT,out 来源: https://blog.51cto.com/14437184/2440906