rfleming Posted April 15, 2008 Share Posted April 15, 2008 Hi all, My current project requires me to return three VARCHAR(45) fields back in a resultset containing 1 VARCHAR. The code needs to return FIRST_NAME MIDDLE_NAME LAST_NAME as one string. I have tried using the + operator in the query statement to no luck. it just outputs a bunch of 0's. I have tried searching google but no luck. Any ideas? Version: 5.0 The table's CREATE code CREATE TABLE `people` ( `PEOPLE_ID` int(10) unsigned NOT NULL auto_increment, `LAST_NAME` varchar(45) NOT NULL, `FIRST_NAME` varchar(45) NOT NULL, `MIDDLE_NAME` varchar(45) NOT NULL, PRIMARY KEY (`PEOPLE_ID`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1 I think that is all the info i have on it. Yell at me if i forgot anything. Thank you, Quote Link to comment Share on other sites More sharing options...
AP81 Posted April 15, 2008 Share Posted April 15, 2008 Use the MySQL concat_ws function. This will allow you to concatenate multiple fields with a separator of choice, which in your case is space. SELECT CONCAT_WS(' ', FIRST_NAME, MIDDLE_NAME, LAST_NAME) AS NAME FROM people Quote Link to comment Share on other sites More sharing options...
rfleming Posted April 15, 2008 Author Share Posted April 15, 2008 Perfect thank you very much Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.