Want to use MYSQL to do a custom function, but is always an error, please have a look at, be obliged!
CREATE function GetCharIndexNum (` @ findstring ` varchar (255), ` @ string ` varchar (255)) Returns the int
The BEGIN Declare ` @ location ` int. Declare ` @ num ` int.
The set @ num=0; The set @ location=charindex (@ findstring, @ string); While @ the location & gt; 0 do The begin The set @ num=@ num + 1; Set @ string=the substring (@ string, @ location + 1, len (@ string)); The set @ location=charindex (@ findstring, @ string);
End Return the @ num
END
CodePudding user response:
Declare ` @ location ` int. Variables don't add @
And should stick to the content of the error come out,