MySQL CReate Function Syntax Error
I'm trying to create function using phpmyadmin/mysql console. Without any luck. I'm getting info of syntax error.
Can anybody take a look on this function?
CREATE FUNCTION fnCategoryList
(
@NewsID INT
)
RETURNS VARCHAR(1000)
AS
BEGIN
DECLARE @CategoryList VARCHAR(1000)
SET @CategoryList = ''
SELECT @CategoryList = COALESCE(@CategoryList + ',','') + C.[Name]
FROM news_开发者_C百科categories AS NC
INNER JOIN categories AS C
ON NC.CategoryID = C.ID
WHERE NC.NewsID = @NewsID
RETURN @CategoryList
END
This is not correct syntax for a MySQL function. That's why you get a syntax error.
http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
Did you try to copy this from a different RDBMS?
精彩评论