Home > Database > Mysql Tutorial > mysql自定义Function_MySQL

mysql自定义Function_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:29:55
Original
1177 people have browsed it

bitsCN.com

mysql自定义Function

 

1.建议大家用navicat(专门管理mysql的工具)

2.新建函数-->函数->xia-->下一步-->在请输入例程的参数-->

输入参数{模式(先不用管,以后会介绍,当前任务是先建立一个感性的认识),名,类型}  

我写了两个参数`matchString` varchar(255),`byMatchString` varchar(10)--->下一步

-->在定义栏输入如下:

BEGIN

DECLARE position INT;#声明一个全局变量,相当于c语言的 int position;

SET position=INSTR(matchString,byMatchString);#INSTR()函数是mysql提供的,用于查找第2个参数在第一个参数的位置

IF(position>0) THEN

RETURN("ok");

ELSE

RETURN("sorry");

END IF;

END

3.单击保存,输入函数名。我输入的是    validate    (就是验证的意思)

4.至此自定义函数完毕,如果想知道SQL语句是什么,点击   SQL预览

5.单击运行

6.输入 'abcd','ab'--->确定   如果输入 'abcd','abb'   自己试试

7.以下就不写了,大家应该能明白

其实学习新技术关键在入门,一旦入门就能快速掌握。

这篇文章本人经过深思熟虑后写的,对于新手相当好!

bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template