8.自定义函数综合应用示例
来源:互联网 发布:淘宝详情页文字大小 编辑:程序博客网 时间:2024/06/05 06:21
来源:网易云课堂《精通MySQL存储过程、函数和触发器》课程
讲师:huangxifeng607(黄锡峰)
笔记:
(1)自定义函数示例01
1.需求:输入用户ID,获得accountid, uid, uname组合的UUID值,在全区游戏中作为用户的唯一标识
delimiter $$create function getuuid(my_uid int) returns varchar(30) charset utf8reads sql data #表示子程序包含读数据的语句,但不包含写数据的语句begindeclare uuid varchar(32) default '';select concat(accountid, '_',uid,'_', uname) into uuid from users where uid=my_uid;return uuid;end;#调用
select getuuid(2)
(2)自定义函数示例02
1.需求:输入参数uid,计算uid所在账号下的所有游戏角色的金币总量
delimiter $$create function statgold(my_uid int) returns intreads sql databegindeclare my_accountid int default 0;declare gold_sum int default 0;select accountid into my_accountid from users where uid=my_uid;select sum(gold) into gold_sum from users where accountid=my_accountid;return gold_sum;end;$$delimiter ;#调用
select statgold(2)
1.自定义函数综合应用示例
阅读全文
0 0
- 8.自定义函数综合应用示例
- oracle函数综合应用
- Jsp 自定义标签 三 综合示例
- InputBox函数和MsgBox函数综合示例
- InputBox函数和MsgBox函数综合示例
- 关于线程的综合应用示例
- 变量与函数的综合示例
- 10-变量与函数的综合示例
- flex表格综合应用(可编辑单元格,自定义函数,行间颜色变化,多列头)
- db2自定义函数示例
- Oracle自定义函数示例
- Oracle 自定义函数示例
- 函数 指针 结构体的综合应用
- 43、Power Query-函数综合应用
- ffmpeg综合应用示例(一)——摄像头直播
- 15.存储过程生产环境应用综合示例详解
- MySQL 自定义函数 (Function) 示例
- MySQL自定义函数应用
- 上传图片时,需注意事项
- HTML5基本内容
- Android自定义view的点击事件
- TableView
- 输出随机认证码图片
- 8.自定义函数综合应用示例
- python sort、sorted高级排序技巧
- [codefoces439C]The Intriguing Obsession(组合数学)
- 一、创建Assetbundle 在unity3d开发的游戏中,无论模型,音频,还是图片等,我们都做成Prefab,然后打包成Assetbundle,方便我们后面的使用,来达到资源的更新。
- 日期控件
- Linux内存清理
- 二叉搜索树转化为双向链表
- mysql建表date类型不能设置默认值
- Different Ways to Add Parentheses