{"id":92,"date":"2023-05-06T03:20:50","date_gmt":"2023-05-06T03:20:50","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=92"},"modified":"2023-05-06T03:20:50","modified_gmt":"2023-05-06T03:20:50","slug":"what-are-mysql-functions-in-php","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/06\/what-are-mysql-functions-in-php\/","title":{"rendered":"What are MySQL functions in PHP?"},"content":{"rendered":"\n<p><strong>Creating a function<\/strong><\/p>\n\n\n\n<p>In MySQL, Function can also be created. A function always returns a value using the return statement. The function can be used in SQL queries.<\/p>\n\n\n\n<p><strong>Syntax<\/strong><\/p>\n\n\n\n<p>CREATE FUNCTION function_name [ (parameter datatype [, parameter datatype]) ]&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>RETURNS return_datatype&nbsp;&nbsp;<\/p>\n\n\n\n<p>BEGIN&nbsp;&nbsp;<\/p>\n\n\n\n<p>Declaration_section&nbsp;&nbsp;<\/p>\n\n\n\n<p>Executable_section&nbsp;&nbsp;<\/p>\n\n\n\n<p>END;&nbsp;&nbsp;<\/p>\n\n\n\n<p><strong>Parameter:<\/strong><\/p>\n\n\n\n<p>Function_name: name of the function<\/p>\n\n\n\n<p>Parameter: number of parameters. It can be one or more than one.<\/p>\n\n\n\n<p>return_datatype: return value datatype of the function<\/p>\n\n\n\n<p>declaration_section: all variables are declared.<\/p>\n\n\n\n<p>executable_section: code for the function is written here.<\/p>\n\n\n\n<p>DELIMITER $$&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>CREATE FUNCTION get_designation_name(d_id INT) RETURNS VARCHAR( 20 )&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>BEGIN&nbsp;&nbsp;&nbsp;<\/p>\n\n\n\n<p>DECLARE de_name VARCHAR( 20 ) DEFAULT &#8220;&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>SELECT name INTO de_name FROM designation WHERE id = d_id;&nbsp;&nbsp;<\/p>\n\n\n\n<p>RETURN de_name;&nbsp;&nbsp;<\/p>\n\n\n\n<p>END $$<\/p>\n\n\n\n<p><strong>Drop a function<\/strong><\/p>\n\n\n\n<p>In MySQL Function can also be dropped. When A function id is dropped, it is removed from the database.<\/p>\n\n\n\n<p><strong>Syntax:<\/strong><\/p>\n\n\n\n<p>Drop function [ IF EXISTS ] function_name;&nbsp;&nbsp;<\/p>\n\n\n\n<p><strong>Parameter<\/strong><\/p>\n\n\n\n<p>function_name: name of the function to be dropped.<\/p>\n\n\n\n<p>drop function get_designation_name;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a function In MySQL, Function can also be created. A function always returns a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/92"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=92"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/92\/revisions"}],"predecessor-version":[{"id":93,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/92\/revisions\/93"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}