码迷,mamicode.com
首页 > 数据库 > 详细

MySQL函数

时间:2015-08-26 12:23:36      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:mysql   函数   

标量函数

实例1

mysql> create function LocateWords
    -> (s CHAR(20),t CHAR(20))
    -> RETURNS int(11)
    -> return locate(t,s);
mysql> select LocateWords(‘abcdabcaba‘,‘da‘);


实例2

mysql> CREATE FUNCTION Fun_GetQuesCntByClass
    -> (
    -> c bigint
    -> )
    -> returns int
    -> begin
    -> declare x int;
    -> select count(1) into x from Ques where classid=c;
    -> return (x);
    -> end;
mysql> select Fun_GetQuesCntByClass(1);


注意:

MySQL没有像MSSQL的表值函数(用存储过程实现)


本文出自 “sukun” 博客,请务必保留此出处http://sukunwu.blog.51cto.com/10453116/1688341

MySQL函数

标签:mysql   函数   

原文地址:http://sukunwu.blog.51cto.com/10453116/1688341

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!