mysql函数详细说明
2014-08-14 00:00
274 查看
摘要: mysql函数详细说明
老是喜欢忘记以前的mysql语法;
老是喜欢忘记以前的mysql语法;
# 开头定义所属用户、函数名称、参数、返回值、编码 CREATE DEFINER=`admin`@`%` FUNCTION `gethotwordsbyconsultid`(`p_id` int) RETURNS varchar(5000) CHARSET utf8 BEGIN #定义返回值 declare v_result varchar(1000) default ''; #定义临时变量 declare v_tmp varchar(150) default ''; #定义游标是否循环完毕,0表示false,默认没有循环完毕 declare done int default 0; #定义游标 declare v_cur cursor for select a.wordsName from t_help_hotwords a inner join t_help_hot_consult b on a.id = b.hotId and b.consultId = p_id; #定义游标完成,1表示true,代表循环完毕,这里用exception的handler实现 declare continue handler for not found set done = 1; #打开游标 open v_cur; #开始循环 repeat #填值 fetch v_cur into v_tmp; #这里not done代表not 0,也就是not false,即true。 if not done then #设置值,拼接字符串 set v_result = concat(v_result,',',v_tmp); end if; #这里只有done为1,也就是true的时候终止循环 until done end repeat; #关闭游标 close v_cur; #返回值 return v_result; END
相关文章推荐
- JNI技术实践小结--原理分析和详细步骤截图说明
- .net GetCallbackEventReference参数说明和详细使用
- node.js在windows下的学习笔记(7)---express的app.js的详细配置说明
- PHP中$_SERVER的详细参数与说明介绍
- phpmailer详细中文使用说明+例子
- 进一步详细说明MFC中Win消息处理、运行机制
- 【转载】JQUERY标签选择器详细说明
- RedHat linux RPM命令详细使用说明
- HighCharts 详细使用及API文档说明
- Android中文件类File的详细使用说明
- Google App Engine的app.yaml详细说明
- [转]图解CSS的padding,margin,border属性(详细介绍及举例说明)
- Xamarin.iOS-UICollectionView详细使用说明【控件篇】
- Dynamic OCT 和 Dynamic ODT 详细说明
- mysqldump参数详细说明
- STM32内部RAM在线调试配置方法及详细说明(基于Keil开发工具)
- JAVA MAIL 配置项详细说明
- 非常完善的Log4net详细说明
- Mysql备份还原数据库之mysqldump实例及参数详细说明
- DispatchAction的详细说明