|
Question : How to create simple FUNCTION SQL and DO FUNCTION CALL
|
|
MYSQL Mind to show me some example on How to create simple FUNCTION SQL and DO FUNCTION CALL and show result if can
Also can you explain abit why we need to use FUNCTION SQL?
|
|
Answer : How to create simple FUNCTION SQL and DO FUNCTION CALL
|
|
The link that elimesika supplied is really very good... answers all your questions.
But it does not have to be code - it can be SQL code....
delimiter // CREATE FUCNTION HelloWorld() RETURNS VARCHAR(20) BEGIN RETURN Hello World; END // select HelloWorld() //
or something more adventurous from on-line help... and the the person who submitted it was richardkmiller
CREATE FUNCTION domain_of_url (url TEXT) RETURNS varchar(255) RETURN SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING "https://" FROM TRIM(LEADING "http://" FROM TRIM(url))), "/", 1), ":", 1), ".", if(url LIKE "%.org.__%" OR url LIKE "%.net.__%" OR url LIKE "%.com.__%" OR url LIKE "%.__.us%" OR url LIKE "%.co.__%" OR url LIKE "%.__.uk%", -3, -2) );
SELECT domain_of_url(" http://www.richardkmiller.com:80/blog/ ") AS domain;
Have a look at : http://www.revealnet.com/newsletter-v6/0105_D.htm and part 2 on : http://www.quest-pipelines.com/newsletter-v6/0205_D.htm
|
|
|
|