问题描述
大家好,
我的数据库中有员工详细信息,他们的名字在
字段中给出(名字,中间名,姓)。当我尝试通过他们的名字获取员工的详细信息。
选择*来自Employeedetails
Concat(名字,'',中间名, '',姓氏)='Maria Francis Desosa'
工作正常
当我尝试获取没有中间名的员工返回零。所以我试试
选择*来自Employeedetails
Concat(IFNULL(ER.firstname,'') ),'',IFNULL(ER.middlename,''),'',IFNULL(ER.lastname,'')
='Maria Desosa'
仍然没有得到数据。任何人都知道如何检索没有中间名的数据
谢谢
parithi
Hi All,
I have a Employee details in my database their name are given in the
field(firstname,middlename,lastname). when i try to fetch the employee details by their name .
Select * From Employeedetails where
Concat(firstname,'',middlename,'',lastname)='Maria Francis Desosa'
It Works Fine
When i try to fetch Employee who does not have middle name it return zero. so i try
Select * From Employeedetails where
Concat(IFNULL(ER.firstname,' '),' ',IFNULL(ER.middlename,''),'',IFNULL(ER.lastname,'')
='Maria Desosa'
Still this not getting the data. can any body know how to retrieve the data who does not have middlename
Thanks
parithi
推荐答案
SELECT CONCAT(FirstName,CASE WHEN ISNULL(MiddleName,'')='' THEN '' ELSE ' ' + MiddleName END, ' ',LastName) FROM CustomerMaster
这篇关于MySql查询连接字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!