Mega Code Archive

 
Categories / MySQL Tutorial / Procedure Function
 

A function that takes a parameter, performs an operation using an SQL function, and returns the result

In this case, it is unnecessary to use delimiter because the function definition contains no internal ; statement delimiters: mysql> mysql> CREATE FUNCTION hello (s CHAR(20)) RETURNS CHAR(50)     ->     RETURN CONCAT('Hello, ',s,'!'); Query OK, 0 rows affected (0.00 sec) mysql> mysql> SELECT hello('world'); +----------------+ | hello('world') | +----------------+ | Hello, world!  | +----------------+ 1 row in set (0.00 sec) mysql> mysql> drop function hello; Query OK, 0 rows affected (0.00 sec) mysql>