Example: https://www.cnblogs.com/DearDWJ/p/6640626.html
But I want to create the function made a mistake when he write what reason be? , to solve the
CodePudding user response:
You this is a mysql, your code is baidu MSSQL, you use the following a try, I also am baidu to
USE ` database name `;
The DROP function IF the EXISTS ` firstletter `;
DELIMITER $$
USE ` database name ` $$
The CREATE DEFINER=` root ` @ % ` ` FUNCTION ` firstletter ` (name varchar (255)) RETURNS a varchar (255) CHARSET utf8
The BEGIN
Declare the result varchar (255);
Set the result=elt (interval (conv (hex (left (the convert (name using GBK), 1)), 16, 18),
Xb2c1 xb0a1 0, 0 xb0c5, 0, 0 xb4ee, 0 xb6ea, 0 xb7a2, 0 xb8c1, 0 xb9fe, 0 xbbf7,
Xc2e8 xbfa6 0, 0 xc0ac, 0, 0 xc4c3, 0 xc5b6, 0 xc5be, 0 xc6da, 0 xc8bb,
Xcdda xc8f6 0, 0 xcbfa, 0, 0 xcef4, 0 xd1b9, 0 xd4d1),
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J' and 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Y', 'Z');
RETURN the result.
END $$
DELIMITER ;