答案 0 :(得分:0)
错误来自mysql表名称中Em_
和gender
之间的空格。但是,如果必须使用UNION,请考虑使用这些查询而不是您的查询
SELECT '' AS 'Employes Name ', Dep_FName as 'Dependant Name '
FROM evnt_db.dependent as d
WHERE Dep_gender='F'
UNION
SELECT Em_FName AS 'Employes Name ', '' as 'Dependant Name '
FROM evnt_db.employee as e,evnt_db.dependent as d
WHERE Em_gender='F' ;
此查询将为您提供一列包含所有从属名称的列,以及一列包含所有雇员名称的列。如果另一列中有值,则每一列将为空白。 如果只想将所有列放在一列中,则可以执行以下操作:
SELECT Dep_FName as 'Dependant Name ', 'Dependant' as Type
FROM evnt_db.dependent as d
WHERE Dep_gender='F'
UNION
SELECT Em_FName AS 'Employes Name ', 'employee' as Type
FROM evnt_db.employee as e,evnt_db.dependent as d
WHERE Em_gender='F' ;
这将在一个列中为您提供所有名称,在另一列中为您提供类型。
顺便说一句:我很确定我能帮助您作弊