Click here to Skip to main content
15,891,597 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Select RoomNo, IDNumber, Lastname, Firstname, Middlename, Course,CONCAT(Lastname,',',Firstname,'',Middlename) as Fullname FROM tblresinformation 
When I get the result it display like this(Lastname,FirstnameMiddlename).Now i want to know how to put space between Firstname and Middlename. The result should be like this(Lastname,Firstname Middlename). Thank you in advance.
Posted
Updated 26-Jul-15 2:39am
v2

1 solution

Not sure if I understand correctly but simply put a space in the separator string
SQL
CONCAT(Lastname,',',Firstname,' ',Middlename) as Fullname

However, remember that if any of the columns is null, the result is null. So you probably want to use
SQL
CONCAT(Lastname, ',', IFNULL(Firstname, ''), ' ' , IFNULL(Middlename, ''))
 
Share this answer
 
v2
Comments
Suvendu Shekhar Giri 26-Jul-15 9:15am    
5ed for adding suggestion for using IFNULL().
Wendelius 26-Jul-15 9:44am    
Thank you :)
roldjer 26-Jul-15 9:44am    
tnx for the info
Wendelius 26-Jul-15 9:46am    
You're welcome.

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