标签:te pro var inner roc user join sql har 案例
#案例:根据女神名,返回对应的男神名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$
标签:te pro var inner roc user join sql har 案例
原文地址:https://blog.51cto.com/14437184/2440906