I'm quite new to MySql. I'm trying to create a function:
CREATE FUNCTION GetDefaultLangText(tableName VARCHAR(50), fieldName VARCHAR(50), primaryFieldName VARCHAR(50), langID INT(10),
defaultLangID INT(10), itemID INT(10), actValue VARCHAR(200)) RETURNS VARCHAR(200)
BEGIN
DECLARE sqlString VARCHAR(200);
SET sqlString = CONCAT(CONCAT('(SELECT ', fieldName,
CONCAT(' FROM ', tableName, ' WHERE LangID = ')), CONCAT(defaultLangID ,' AND ',
CONCAT(primaryFieldName, ' = ', CONCAT(itemID, ')', NULL))));
RETURN IF(actValue = NULL OR (CHAR_LENGTH(actValue) = 0), sqlString, actValue);
END;
However this gives me a syntax error can anyone help please ? I'm not sure what I'm doing wrong since I followed the online documentation