Active_t
Active_t

Reputation: 177

MYSQL merge columns

I'm using MySQL and do a select:

SELECT LTRIM(Firstname + ' ' Lastname) AS Fullname FROM Persons

My result is 0 for every result.

Even if i remove the LTRIM, Using CONCAT is giving the same problem.

Upvotes: 1

Views: 675

Answers (1)

Piskvor left the building
Piskvor left the building

Reputation: 92762

You are arithmetically adding the string values together; unless you have "1ohn 5mith" in the db, this will always be 0.

Does SELECT LTRIM(CONCAT(Firstname,' ',Lastname)) AS Fullname FROM Persons give you the same problem? (note that there are 3 parameters to CONCAT() here: Firstname, a one-character string containing a space, and Lastname; this function takes as many arguments as you throw at it and outputs them as a string)

Upvotes: 4

Related Questions