请帮忙 !!我在创建此功能时遇到错误 [英] Please Help !! I am getting ERROR while creating this FUNCTION

查看:80
本文介绍了请帮忙 !!我在创建此功能时遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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;







错误:



SQL执行错误#1064。来自数据库的回复:



您的SQL语法有错误;检查

对应于你的MySQL服务器版本的手册,使用正确的语法

'UNION

附近(SELECT用户名FROM usersmaster where usertype ='admin'和

usercode ='第7行




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

推荐答案

尝试通过检查出来自行解决问题:create-function-examples [ ^ ]
Try fixing the problem yourself by checking this out: create-function-examples[^]


这篇关于请帮忙 !!我在创建此功能时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆