Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenating two strings in Sql with space [duplicate]

Tags:

mysql

I am trying to concatenate two strings having space between them.The script below concatenates but it doesn't give any space between them.

UPDATE INS  
set INS.UpdateBy = x.FNameTxt +''+''+''+ x.LNameTxt 
From #Insured INS
Inner Join 
(
select I.ModSystemUserId,SU.FNameTxt,SU.LNameTxt
from Insured I
inner join dbo.SystemUser SU
on I.ModSystemUserId = Su.SystemUserId
where I.InsuredId = @insuredId
) AS X
on INS.Insuredid =@insuredId 

I am doing this INS.UpdateBy = x.FNameTxt +''+''+''+ x.LNameTxt

x.FNameTx = John
x.LNameTxt = Doe

result: JohnDoe i need space between them

like image 979
JuniorDev Avatar asked Jan 11 '23 13:01

JuniorDev


1 Answers

Try this

UPDATE INS  
  set INS.UpdateBy = CONCAT(x.FNameTxt,'  ',x.LNameTxt) ....

CONCAT(str1,str2,...)

like image 172
M Khalid Junaid Avatar answered Feb 06 '23 00:02

M Khalid Junaid