MySQL database Advanced (ii)--Custom functions

Source: Internet
Author: User
Tags case statement define local ming rand

MySQL database Advanced (ii)--Custom function One, introduction to custom functions

Custom Functions (user-defined function UDFs) are a way to extend MySQL, with the same usage as built-in functions.
Two prerequisites for a custom function:
A, Parameters
B, return value (must have). The function can return any type of value.

Ii. use of custom functions 1. Custom Function syntax
CREATE?FUNCTION?function_name(parameter_nametype,[parameter_name type,...])RETURNS?{STRING|INTEGER|REAL}runtime_body

More complex syntax can be used in the body of a function, such as composite structure/Process Control/Any SQL statement/definition variables.
The syntax for creating a custom function with a composite structure is as follows:

DELIMITER //CREATE?FUNCTION?function_name(parameter_nametype,[parameter_name type,...])RETURNS?{STRING|INTEGER|REAL}BEGIN//bodyEND//      /* 此处的”//“为告诉系统函数定义结束 */

When a function body needs to execute more than one statement, use begin ... End statement, and when writing the function body content, you need to use the Delimiter keyword to separate Mr. Foo to something else, otherwise write the statement ";" will be executed directly, resulting in the failure of the function writing.

2. Create a custom function with a composite structure function body

In the body of a function, if you include multiple statements, you need to put multiple statements into the BEGIN ... The end statement block.
? Composite structures can include declarations, loops, and control structures.

3. Define local variables in custom functions

Syntax for variable definitions:
DECLARE var_name[,varname]...date_type [DEFAULT VALUE];
Syntax to assign a value to a variable:

SET parameter_name = value[,parameter_name = value...]SELECT INTO parameter_name

Instance:

DECLARE x int;SELECT COUNT(id) FROM tdb_name INTO x;SET @x = 100;
4. Process Control

A custom function can use Process control to control the execution of a statement.
In MySQL, you can use if statements, case statements, loop statements, leave statements, iterate statements, repeat statements, and while statements for process control.
A, if statement
The IF statement is used to make conditional judgments. Depending on whether the condition is met, different statements are executed. The basic form of its syntax is as follows:

IF search_condition THEN statement_list    [ELSEIF search_condition THEN statement_list] ...    

The search_condition parameter represents the conditional judgment statement; The Statement_list parameter represents the execution statement for different conditions.
The IF statement needs to end with End If.
If statement instance:

IF age>20 THEN SET @[email protected]+1;  ELSEIF age=20 THEN SET @[email protected]+1;  ELSE SET @[email protected]+1;  

B. Case statement
Case statements are also used to make conditional judgments, which can be more complex than if statements. The basic form of the case statement is as follows:

CASE case_value      WHEN when_value THEN statement_list      [WHEN when_value THEN statement_list] ...      

The Case_value parameter represents the variable of the condition judgment; the When_value parameter represents the value of the variable;
The Statement_list parameter represents the execution statement for different when_value values.
Case Statement instance:

The case statement has another form, with the following syntax:

CASE        WHEN search_condition THEN statement_list        [WHEN search_condition THEN statement_list] ...        

The search_condition parameter represents the conditional judgment statement; The Statement_list parameter represents the execution statement for different conditions.
Case Statement instance:

CASE        WHEN age=20 THEN SET @[email protected]+1;        

C, Loop statement
The Loop statement enables certain statements to be executed repeatedly, implementing a simple loop. However, the Loop statement itself does not have a statement to stop looping, it must encounter a leave statement, and so on to stop the loop.
The basic form of the loop statement syntax is as follows:

The Begin_label parameter and the End_label parameter represent the loop start and end flags respectively, the two flags must be the same, and both can be omitted; the Statement_list parameter represents the statement that needs to be executed in a loop.
Loop Statement instance:

add_num: LOOP  SET @[email protected]+1;  

D, leave statements
The leave statement is primarily used to jump out of loop control. Its grammatical form is as follows:
LEAVE label
The label parameter represents the flag for the loop.
Leave statement instance:

E, iterate statements
The iterate statement is also a statement used to jump out of a loop. However, the iterate statement jumps out of the loop and then goes directly to the next loop.
The iterate statement can only appear within the loop, REPEAT, and while statements.
The basic syntax form of the iterate statement is as follows:
ITERATE label
Where the label parameter represents the loop's flag.
Iterate Statement instance:

The leave statement is to jump out of the entire loop and then execute the program behind the loop. The iterate statement jumps out of the loop and then into the next loop.
F, repeat statements
The repeat statement is a conditional-controlled loop statement. When certain conditions are met, the loop statement is jumped out. The basic syntax form of the repeat statement is as follows:

The repeat loop ends with end repeat.
Where the statement_list parameter represents the execution statement of the loop, and the search_condition parameter represents the condition that ends the loop, and the loop ends when the condition is met.

G, while statement
The while statement is also a conditional-controlled loop statement. But the while statement and the repeat statement are not the same.
The While statement executes the statement within the loop when the condition is met.
The basic syntax form of the while statement is as follows:

The while loop needs to end with the end while.
Where the search_condition parameter indicates the condition of the loop execution, and the loop executes when the condition is satisfied;
The Statement_list parameter represents the execution statement for the loop.

5. Delete Custom Functions

DROP FUNCTION functionName;

6. Calls to custom functions

SELECT function_name(parameter_value,...);

Iii. examples of custom functions 1. Judging students ' achievements according to their grades

The following functions can output poor results based on the range of input values.
Less than 60 failed
60-69 need to work hard
70-79 Results Medium
80-89 Excellent results
90-100 Good grades

create function getGrade(mark int)returns VARCHAR(20)beginreturn (       case FLOOR(mark/10)        when 5 then ‘不及格‘        when 6 then ‘继续努力‘        when 7 then ‘成绩良好‘        else ‘成绩优秀‘       end);END
2. Chinese Pinyin function

You need to first create a table that stores the character set GBK's code and the phonetic correspondence between them.

CREATE TABLE IF NOT EXISTS `t_base_pinyin` (  `pin_yin_` varchar(255) CHARACTER SET gbk NOT NULL,  `code_` int(11) NOT NULL,  PRIMARY KEY (`code_`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Insert data:
INSERT into T_base_pinyin (pin_yin_,code_) VALUES ("A", 20319), ("AI", 20317), ("an", 20304), ("Ang", 20295), ("AO", 20292), ("Ba", 20283), ("Bai", 20265), ("Ban", 20257), ("Bang", 20242), ("Bao", 20230), ("Bei", 20051), ("Ben", 20036), ("Beng", 20032), ("Bi", 20026), ("Bian", 20002), ("Biao", 19990), ("Bie", 19986), ("Bin", 19982), ("Bing", 19976), ("Bo", 19805), ("Bu ", 19784), (" Ca ", 19775), (" Cai ", 19774), (" Can ", 19763), (" Cang ", 19756), (" Cao ", 19751), (" Ce ", 19746), (" CEng ", 19741), (" Cha ", 19739), (" Chai ", 19728), (" Chan ", 19725), (" Chang ", 19715), (" Chao ", 19540), (" Che ", 19531), (" Chen ", 19525), (" Cheng " , 19515), ("Chi", 19500), ("Chong", 19484), ("Chou", 19479), ("Chu", 19467), ("Chuai", 19289), ("Chuan", 19288), (Chuang), 19281), ("Chui", 19275), ("Chun", 19270), ("Chuo", 19263), ("Ci", 19261), ("Cong", 19249), ("Cou", 19243), ("Cu", 19242), (" Cuan ", 19238), (" Cui ", 19235), (" Cun ", 19227), (" CuO ", 19224), (" Da ", 19218), (" Dai ", 19212), (" Dan ", 19038), (" Dang ", 19023) , ("DAO", 19018), ("De", 19006), ("Deng", 19003), ("Di", 18996), ("Di",An ", 18977), (" Diao ", 18961), (' Die ', 18952), (" Ding ", 18783), (" Diu ", 18774), (" Dong ", 18773), (" Dou ", 18763), (" Du ", 18756) , ("Duan", 18741), ("DUI", 18735), ("Dun", 18731), ("Duo", 18722), ("E", 18710), ("en", 18697), ("ER", 18696), ("FA", 18526), ( "Fan", 18518), ("Fang", 18501), ("Fei", 18490), ("Fen", 18478), ("Feng", 18463), ("Fo", 18448), ("Fou", 18447), ("Fu", 18446) , ("Ga", 18239), ("Gai", 18237), ("Gan", 18231), ("Gang", 18220), ("Gao", 18211), ("GE", 18201), ("GEi", 18184), ("Gen", 18183 ), ("Geng", "18181"), ("Gong", 18012), ("Gou", 17997), ("Gu", 17988), ("Gua", 17970), ("Guai", 17964), ("Guan", 17961), ("" "" "" The Guang ", 17950), (" GUI ", 17947), (" Gun ", 17931), (" Guo ", 17928), (" Ha ", 17922), (" Hai ", 17759), (" Han ", 17752), (" Hang ", 17733), (" Hao ", 17730), (" he ", 17721), (" Hei ", 17703), (" Hen ", 17701), (" Heng ", 17697), (" Hong ", 17692), (" Hou ", 17683), (" Hu ", 17676), ("Hua", 17496), ("Huai", 17487), ("Huan", 17482), ("Huang", 17468), ("Hui", 17454), ("Hun", 17433), ("Huo", 17427), ("Ji", 17417), ("Jia", 17202), ("Jian", 17185), ("Jiang", 16983), ("JiaO ", 16970), (" Jie ", 16942), (" Jin ", 16915), (" Jing ", 16733), (" Jiong ", 16708), (" JIU ", 16706), (" Ju ", 16689), (" Juan ", 16664) , ("Jue", 16657), ("June", 16647), ("Ka", 16474), ("Kai", 16470), ("Kan", 16465), ("Kang", 16459), ("Kao", 16452), ("Ke", 16448 ), ("Ken", 16433), ("Keng", 16429), ("Kong", 16427), ("Kou", 16423), ("Ku", 16419), ("Kua", 16412), ("Kuai", 16407), ("Kuan", 16403), ("Kuang", 16401), ("Kui", 16393), ("Kun", 16220), ("Kuo", 16216), ("La", 16212), ("Lai", 16205), ("LAN", 16202), (" Lang ", 16187), (" Lao ", 16180), (" Le ", 16171), (" Lei ", 16169), (" Leng ", 16158), (" Li ", 16155), (" Lia ", 15959), (" Lian ", 15958) , ("Liang", 15944), ("Liao", 15933), ("Lie", 15920), ("Lin", 15915), ("Ling", 15903), ("Liu", 15889), ("Long", 15878), ("Lou" , 15707), ("Lu", 15701), ("LV", 15681), ("Luan", 15667), ("Lue", 15661), ("Lun", 15659), ("Luo", 15652), ("Ma", 15640), ("Mai" , 15631), ("Man", 15625), ("Mang", 15454), ("Mao", 15448), ("Me", 15436), ("Mei", 15435), ("The Men", 15419), ("Meng", 15416), (" Mi ", 15408), (" Mian ", 15394), (" Miao ", 15385), (" Mie ", 15377), ("Min ", 15375), (" Ming ", 15369), (" Miu ", 15363), (" Mo ", 15362), (" MoU ", 15183), (" Mu ", 15180), (" NA ", 15165), (" Nai ", 15158), (" Nan ", 15153), (" Nang ", 15150), (" Nao ", 15149), (" Ne ", 15144), (" Nei ", 15143), (" nen ", 15141), (" Neng ", 15140), (" Ni ", 15139), ("Nian", 15128), ("Niang", 15121), ("Niao", 15119), ("Nie", 15117), ("Nin", 15110), ("Ning", 15109), ("Niu", 14941), (Nong ") , 14937), ("Nu", 14933), ("NV", 14930), ("Nuan", 14929), ("Nue", 14928), ("Nuo", 14926), ("O", 14922), ("ou", 14921), ("Pa", 14914), ("Pai", 14908), ("Pan", 14902), ("Pang", 14894), ("Pao", 14889), ("Pei", 14882), ("pen", 14873), ("Peng", 14871), (" Pi ", 14857), (" Pian ", 14678), (" Piao ", 14674), (" Pie ", 14670), (" Pin ", 14668), (" Ping ", 14663), (" Po ", 14654), (" Pu ", 14645), ("Qi", 14630), ("QIA", 14594), ("Qian", 14429), ("Qiang", 14407), ("Qiao", 14399), ("Qie", 14384), ("Qin", 14379), (Qing), 14368), ("Qiong", 14355), ("Qiu", 14353), ("Qu", 14345), ("Quan", 14170), ("que", 14159), ("Qun", 14151), ("ran", 14149), (" Rang ", 14145), (" Rao ", 14140), (" Re ", 14137), (" Ren ", 14135), (" RenG ", 14125), (" Ri ", 14123), (" Rong ", 14122), (" Rou ", 14112), (" Ru ", 14109), (" Ruan ", 14099), (" Rui ", 14097), (" Run ", 14094), (" Ruo ", 14092), (" sa ", 14090), (" Sai ", 14087), (" San ", 14083), (" sang ", 13917), (" Sao ", 13914), (" se ", 13910), (" Sen ", 13907), ( "Seng", 13906), ("Sha", 13905), ("Shai", 13896), ("Shan", 13894), ("Shang", 13878), ("Shao", 13870), ("she", 13859), ("Shen" , 13847), ("Sheng", 13831), ("Shi", 13658), ("Shou", 13611), ("Shu", 13601), ("Shua", 13406), ("Shuai", 13404), "Shuan", 13400), ("Shuang", 13398), ("Shui", 13395), ("Shun", 13391), ("Shuo", 13387), ("Si", 13383), ("song", 13367), ("Sou", 13359) , ("Su", 13356), ("Suan", 13343), ("Sui", 13340), ("Sun", 13329), ("suo", 13326), ("Ta", 13318), ("Tai", 13147), ("Tan", 13138 ), ("Tang", 13120), ("Tao", 13107), ("TE", 13096), ("Teng", 13095), ("Ti", 13091), ("Tian", 13076), ("Tiao", 13068), ("Tie", 13063), ("Ting", 13060), ("Tong", 12888), ("Tou", 12875), ("Tu", 12871), ("Tuan", 12860), ("Tui", 12858), ("Tun", 12852), (" Tuo ", 12849), (" WA ", 12838), (" Wai ", 12831), (" Wan ", 12829), (" Wang", 12812), (" Wei ", 12802), (" Wen ", 12607), (" Weng ", 12597), (" Wo ", 12594), (" WU ", 12585), (" Xi ", 12556), (" Xia ", 12359), (" Xian ", 12346), (" Xiang ", 12320), (" Xiao ", 12300), (" Xie ", 12120), (" Xin ", 12099), (" Xing ", 12089), (" Xiong ", and" 12074 "), (" The "," [Xiu "), 12067), ("Xu", 12058), ("Xuan", 12039), ("Xue", 11867), ("Xun", 11861), ("Ya", 11847), ("Yan", 11831), ("Yang", 11798), ("Yao ", 11781), (" Ye ", 11604), (" Yi ", 11589), (" Yin ", 11536), (" Ying ", 11358), (" Yo ", 11340), (" Yong ", 11339), (" You ", 11324), (" Yu ", 11303), (" Yuan ", 11097), (" Yue ", 11077), (" Yun ", 11067), (" Za ", 11055), (" Zai ", 11052), (" Zan ", 11045), (" Zang ", 11041), (" Zao ", 11038), (" Ze ", 11024), (" Zei ", 11020), (" Zen, "11019), (" Zeng ", 11018), (" Zha ", 11014), (" Zhai ", 10838), (" Zhan ", 10832 ), ("Zhang", 10815), ("Zhao", 10800), ("Zhe", 10790), ("Zhen", 10780), ("Zheng", 10764), ("Zhi", 10587), ("Zhong", 10544), (" Zhou ", 10533), (" Zhu ", 10519), (" Zhua ", 10331), (" Zhuai ", 10329), (" Zhuan ", 10328), (" Zhuang ", 10322), (" Zhui ", 10315), (" Zhun ", 10309), (" Zhuo ", 10307), (" Zi ", 10296), (" Zong ", 10281), (" ZoU ", 10274), (" Zu ", 10270), (" Zuan ", 10262), (" Zui ", 10260), (" Zun ", 10256), (" Zuo ", 10254);
The function of generating pinyin for Chinese characters:

DROP FUNCTION IF EXISTS PINYIN;    CREATE FUNCTION PINYIN (NAME VARCHAR (255) CHARSET GBK) RETURNS VARCHAR (255) CHARSET gbkbegin DECLARE mycode INT;    DECLARE Tmp_lcode VARCHAR (2) CHARSET GBK;    DECLARE Lcode INT;    DECLARE Tmp_rcode VARCHAR (2) CHARSET GBK;    DECLARE Rcode INT;    DECLARE mypy VARCHAR (255) CHARSET GBK DEFAULT ';    DECLARE LP INT;    SET mycode = 0;    SET LP = 1;    SET NAME = HEX (name);        While LP < LENGTH (name) do SET tmp_lcode = SUBSTRING (name, LP, 2);         SET Lcode = CAST (ASCII (Unhex (Tmp_lcode)) as UNSIGNED);        SET Tmp_rcode = SUBSTRING (NAME, LP + 2, 2);         SET Rcode = CAST (ASCII (Unhex (Tmp_rcode)) as UNSIGNED);            IF lcode > then SET mycode =65536-lcode * 256-rcode;        SELECT CONCAT (Mypy,pin_yin_) to Mypy from T_base_pinyin WHERE code_ >= ABS (mycode) ORDER by Code_ ASC LIMIT 1;        SET LP = LP + 4;   Elseset mypy = CONCAT (Mypy,char (CAST (ASCII (Unhex (NAME, LP, 2)) as SUBSTRING));         SET LP = LP + 2;    END IF;    END while; RETURN LOWER (Mypy); END;
3. Arabic numerals to Chinese characters
Create FUNCTION Tohanzi (N_lowermoney DECIMAL) RETURNS VARCHAR (+) BEGIN Declare v_lowerstr VARCHAR (200); Declare V_upperpart VARCHAR (200); Declare v_upperstr VARCHAR (200); Declare i_i int; Set v_lowerstr = LTRIM (RTRIM (ROUND (n_lowermoney,2))); Set i_i = 1; Set v_upperstr = ';  while (I_i <=char_length (V_LOWERSTR)) does set V_upperpart = CONCAT (case substring (v_lowerstr,char_length (V_LOWERSTR) -i_i + +) when '. ' Then ' $ ' when ' 0 ' and ' 0 ' when ' 1 ' then ' one ' when ' 2 ' then ' if ' 3 ' then ' if ' 4 ' then ' if ' 5 ' then ' when ' ' 6 ' Then ' if ' 7 ' Then ' qi ' when ' 8 ' then ' BA ' if ' 9 ' then ' JIU ' END, case i_i if 1 then ' minute ' when 2 Then ' angle ' when 3 TH  EN "When 4 then" when 5 Then ' pick up ' when 6 then ' "When the 7 Then '" When 8 Then ' "When 9 then ' pick ' when And then ' thousand ' when the ' when ' and ' when ' and ' when ' and ' when ' and ' when ' and ' when ' and ' when ', ' Then ' ' ELSE ' END; Set V_upperstr =concat (V_upperpart, V_UPPERSTR); Set i_i = i_i + 1; End while; Set V_upperstr = REPLACE (V_upperstr, ' 0 pickup ', ' 0 '); Set v_upperstr = REPLACE (V_upperstr, ' 0 bai ', ' 0 '); Set v_upperstr = REPLACE (V_upperstr, ' 0 thousand ', ' 0 '); Set v_upperstr = REPLACE (v_upperstr, ' 000 ', ' 0 '); Set v_upperstr = REPLACE (v_upperstr, ' 00 ', ' 0 '); Set v_upperstr = REPLACE (v_upperstr, ' Certer ', ' whole '); Set v_upperstr = REPLACE (V_upperstr, ' 0 points ', ' whole '); Set v_upperstr = REPLACE (v_upperstr, ' 0 angle ', ' 0 '); Set v_upperstr = REPLACE (V_upperstr, ' 0 yuan ', ' billion Yuan '); Set v_upperstr = REPLACE (V_upperstr, ' billion zero million ', ' billion Yuan '); Set v_upperstr = REPLACE (V_upperstr, ' 0 ', ' billion '); Set v_upperstr = REPLACE (v_upperstr, ' $0 ', ' million '); Set v_upperstr = REPLACE (v_upperstr, ' zero Yuan ', ' million '); Set v_upperstr = REPLACE (V_upperstr, ' 0 ', ' billion '); Set v_upperstr = REPLACE (V_upperstr, ' 0 ', ' million '); Set v_upperstr = REPLACE (V_upperstr, ' 0 yuan ', ' Yuan '); Set v_upperstr = REPLACE (v_upperstr, ' 00 ', ' 0 '); if (' meta ' = substring (v_upperstr,1,1)) then Set v_upperstr = substring (v_upperstr,2, (Char_length (V_UPPERSTR)-1)); End If; if (' 0 ' = substring (v_upperstr,1,1)) then setV_UPPERSTR = substring (v_upperstr,2, (Char_length (V_UPPERSTR)-1)); End If; if (' angle ' = substring (v_upperstr,1,1)) then Set v_upperstr = substring (v_upperstr,2, (Char_length (V_UPPERSTR)-1)); End If; if (' Minute ' = substring (v_upperstr,1,1)) then Set v_upperstr = substring (v_upperstr,2, (Char_length (V_UPPERSTR)-1)); End If; if (' whole ' = substring (v_upperstr,1,1)) then set v_upperstr = ' 0 yuan whole '; End If; return v_upperstr; END
4. The function of randomly generating names

Use three strings to hold the user's name and randomly arrange the combination of adult names from the names using random functions.

Create function Createname () RETURNS varchar (3) begindeclare LN varchar;D eclare MN varchar ($);D eclare FN varchar ( ;D eclare ln_n int;declare mn_n int;declare fn_n INT; SET LN=‘李王张刘陈杨黄赵周吴徐孙朱马胡郭林何高梁郑罗宋谢唐韩曹许邓萧冯曾程蔡彭潘袁于董余苏叶吕魏蒋田杜丁沈姜范江傅钟卢汪戴崔任陆廖姚方金邱夏谭韦贾邹石熊孟秦阎薛侯雷白龙段郝孔邵史毛常万顾赖武康贺严尹钱施牛洪龚‘; SET mn= ' Wei just courageous June Yun Lianjin ring snow rong Love sister Xia Xiang month Ying Yuan Yan Rui van Jia Jia Jong Qin zhen Guidi Ye Shi just hair Wulilin round John Lamberhon say if the Ming Peng present Witchkelen Xiang Xu Chen Shi build home-induced tree inflammation Dehe Jiang Shuhao lu ya Crystal Yue Hwa Qiao Mei Jie Xin litchi think Heart State Cheng Lechaugong pine good thick qing lei people friends Jade Ping red Ah Ling fragrance yan Choi Lan Fengjie Meshujuan the Thai Shengxiong Total June crown Policy Teng nan Banyan Wind Hong Feng strong army ping Bao Dong Wenhui Liming zhi Yuchenliang Renponin Fossengrong National sheng Learn xiang just hair Vuniuli fly bin Fushunshin kwantip Tao Chang into Kang star Day da ' an Yan Jin Lin Jian and Puma first to the earthquake vibration strong will think group Hao Heart State Lechaugong pine good thick qing lei min Yu Jiang Shuhao Liang Zheng Stonehenge fixed round John Lamberhon said if the Ming friend bin Present Witchkelen Xiang Xu Peng ze Chen Shi to build home to the tree inflammation when the Thai Shengxiung June Crown policy Teng Nan Banyan wind and Air Hong '; SET fn= ' Wei just courageous June Yun Lianjin ring snow rong Love sister Xia Xiang month Ying Yuan Yan Rui van Jia Jia Jong Qin zhen Guidi Ye Shi just hair Wulilin round John Lamberhon say if the Ming Peng present Witchkelen Xiang Xu Chen Shi build home-induced tree inflammation Dehe Jiang Shuhao lu ya Crystal Yue Hwa Qiao Mei Jie Xin litchi think Heart State Cheng Lechaugong pine good thick qing lei people friends Jade Ping red Ah Ling fragrance yan Choi Lan Fengjie Meshujuan the Thai Shengxiong Total June crown Policy Teng nan Banyan Wind Hong Feng strong army ping Bao Dong Wenhui Liming zhi Yuchenliang Renponin Fossengrong National sheng Learn xiang just hair Vuniuli fly bin Fushunshin kwantip Tao Chang into Kang star Day da ' an Yan Jin Lin Jian and Puma first to the earthquake vibration strong will think group Hao Heart State Lechaugong pine good thick qing lei min Yu Jiang Shuhao Liang Zheng Stonehenge fixed round John Lamberhon said if the Ming friend bin Present Witchkelen Xiang Xu Peng ze Chen Shi to build home to the tree inflammation when the Thai Shengxiung June Crown policy Teng Nan Banyan wind and Air Hong '; SET ln_n=char_length (LN); SET mn_n=char_length (MN); SET fn_n=char_length (FN), Return Concat (SUBSTRING (Ln,ceil (rand () *ln_n), 1), substring (Mn,ceil (rand () *mn_n), 1), SUBSTRING (Fn,ceil (rand () *fn_n), 1)); End

MySQL database Advanced (ii)--Custom functions

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.