How to create a function with MySQL

Source: Internet
Author: User

previously used SQL SERVER is often used when function , the processing of some data is more convenient, now the database is transferred to MySQL after that, I also want to keep the same function, fortunately MySQL also supports function , now to share under the MySQL in how to create function

Tools / Raw Materials

MySQL

MySQL Workbench

Method / Steps

              1in theMySQLcreated infunctionthe wording andSQL SERVERThere is a difference, first look at theMySQLWhat is the correct wording in thisfunctionThe goal is to return the number of peers based on the age parameter passed and return the results


call our newly created function , we can see from the results that our custom function properly executed, and the following is speaking MySQL Create function things to be aware of when


DELIMITER usage is no longer described, as in stored procedures, I share how to create stored procedures have been described??


It is important to note here that the parameters passed in cannot be the same as the database fields, which I was not aware of before . function It 's never been executed in the ideal state.


in this step we will define the parameters as well as the database fields to see how the function what kind of value will be returned


Although function can also be created successfully, but the return value is not the value we want when we call it. function does not work as we wish, so it is a special reminder that the arguments passed in cannot be the same as the database fields


MySQL the variables defined in the SQL Server It's a lot easier to use without declaring it directly.


< Span style= "COLOR: #262626" > modify function drop create alter error, stored procedure also has the same problem, here do not know whether there is a direct modification of the method I have not found, welcome to Exchange





How to create a function with MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.