concact in mysql

I'm using mysql database in windows.
I'm getting an error when I try this command:
Select concat(LastName, ',', ForeName)AS NewNames from Employees;

Everything is right in the database (names, fields)!
I don't know what is wrong in the code above?
Is there another way to write this SQL command?Thanks for any help.
viktor999Asked:
Who is Participating?
 
cLFlaVAConnect With a Mentor Commented:
Two things to try:

The simple "+" Concatenation:
SELECT LastName + ', ' + ForeName AS NewNames FROM Employees;

The CONCAT_WS() function (concat with separator):
SELECT CONCAT_WS(', ', LastName, ForeName) AS NewNames FROM Employees;
0
 
steve918Commented:
I tried the same select and it worked fine...
0
 
cLFlaVACommented:
Also, what is your error?  Is it "you have an error in your MySQL Syntax near 'AS NewNames from Employees;'?

Because if that's the error, it's because you don't have a space between your ) and your AS.  I had originally assumed that was just a typo on ee, I could be wrong though.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
UmeshMySQL Principle Technical Support EngineerCommented:
try this..
 
Select concat(LastName,',',ForeName)   AS NewNames from Employees;
0
 
cLFlaVACommented:
How is that any different from what has already been said?
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
I didn't see it (I think u have submitted when I was typing.. that time how can I see updated page.. after posting only I saw)
0
 
cLFlaVACommented:
Ahh gotcha - no biggie...

:)
0
 
steve918Commented:
the AS worked fine for me as above concat()AS works fine on mysql 3.23 w/ Fedora Linux
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.