Use of MySQL function will make our coding easier. Function can contain some business logic. |
So I will create MySQL function first using below query: |
DELIMITER // DROP FUNCTION IF EXISTS MyFunction; CREATE FUNCTION MyFunction(p1 INT) RETURNS VARCHAR(50) BEGIN DECLARE v1 VARCHAR(50) DEFAULT ""; SELECT concat(name,'-',roll) INTO v1 FROM table1 WHERE id = p1; RETURN v1; END; // |
So our MySQL function created, now we will list our available MySQL functions using below query: |
SHOW FUNCTION STATUS |
Now we will select/execute MySQL function using below query |
select *,MyFunction(id) as 'function' from table1; |
Which will results like below screenshot: |
|
Showing posts with label mysql-function. Show all posts
Showing posts with label mysql-function. Show all posts
Thursday, June 7, 2018
MySQL > Create Function > Call MySQL Function > Execution MySQL Function > MysQL Show Listed Functions
Subscribe to:
Posts (Atom)