#建立存儲過程或函數實現傳入一個日期,格式化成xx年xx月xx日並返回ide
DELIMITER $ CREATE PROCEDURE pp(IN mydate DATETIME,OUT nowdate VARCHAR(50) ) BEGIN SELECT DATE_FORMAT(mydate,'%y年%m月%d日') INTO nowdate; END $ CALL pp(NOW(),@nowdate)$ SELECT @nowdate$
#建立存儲過程實現傳入女神名稱,返回女神and男神 格式的字符串函數
CREATE PROCEDURE pp2(IN bName VARCHAR(20),OUT tname VARCHAR(50)) BEGIN SELECT CONCAT(bName,'and',IFNULL(bo.boyname,'null')) INTO tname FROM beauty b LEFT JOIN boys bo ON b.boyfriend_id=bo.id WHERE b.name=bName; END $ CALL pp2('小昭',@tname) $ SELECT @tname $
#建立存儲過程,根據傳入的條目數和起始索引,查詢beauty表的記錄code
CREATE PROCEDURE pp3(IN n INT,IN m INT) BEGIN SELECT * FROM beauty LIMIT m,n; END $ CALL pp3(3,5)$