標量函數
實例1:
mysql> create function LocateWords -> (s CHAR(20),t CHAR(20)) -> RETURNS int(11) -> return locate(t,s); mysql> select LocateWords('abcdabcaba','da');
實例2:
mysql> CREATE FUNCTION Fun_GetQuesCntByClass -> ( -> c bigint -> ) -> returns int -> begin -> declare x int; -> select count(1) into x from Ques where classid=c; -> return (x); -> end; mysql> select Fun_GetQuesCntByClass(1);