Solved

concact in mysql

Posted on 2004-09-29
8
445 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:viktor999
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 13

Accepted Solution

by:
cLFlaVA earned 50 total points
ID: 12179931
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
 
LVL 3

Expert Comment

by:steve918
ID: 12179971
I tried the same select and it worked fine...
0
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12180052
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 26

Expert Comment

by:Umesh
ID: 12180076
try this..
 
Select concat(LastName,',',ForeName)   AS NewNames from Employees;
0
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12180137
How is that any different from what has already been said?
0
 
LVL 26

Expert Comment

by:Umesh
ID: 12180190
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
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12180239
Ahh gotcha - no biggie...

:)
0
 
LVL 3

Expert Comment

by:steve918
ID: 12180659
the AS worked fine for me as above concat()AS works fine on mysql 3.23 w/ Fedora Linux
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question