Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
CREATE FUNCTION fn_getAdminNStaffNameByUserCode(
    _userCode varchar(100)
    ) RETURNS varchar(1000) CHARSET utf8
BEGIN
    DECLARE _staffName VARCHAR(1000) ;

    SET _staffName = (SELECT CONCAT(firstName,' ',lastname,' ',middleName) staffname  FROM staff where userCode = _userCode)  UNION
(SELECT username FROM usersmaster where usertype = 'admin' and usercode =_userCode) ;

    RETURN _staffName ;
    END;



Error:

SQL execution error #1064. Response from the database:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'UNION
(SELECT username FROM usersmaster where usertype = 'admin' and
usercode =' at line 7
Posted

1 solution

Try fixing the problem yourself by checking this out: create-function-examples[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900