Daveyboy Posted December 31, 2006 Share Posted December 31, 2006 I looked at the Mysql manual but cant find a way to seperate two strings with a space. For example,when i run this query in php it comes out "firstnamelastname". I want it to be "firstname lastname".$query = "SELECT CONCAT(firstname,lastname) FROM info WHERE id=$id"; Link to comment https://forums.phpfreaks.com/topic/32409-solved-concat-function-with-separator/ Share on other sites More sharing options...
printf Posted December 31, 2006 Share Posted December 31, 2006 Just add a space param between the columns you want to join together.[code]$query = "SELECT CONCAT(firstname, ' ', lastname) AS full_name FROM info WHERE id = " . $id;[/code]printf Link to comment https://forums.phpfreaks.com/topic/32409-solved-concat-function-with-separator/#findComment-150551 Share on other sites More sharing options...
Daveyboy Posted December 31, 2006 Author Share Posted December 31, 2006 thanks! Link to comment https://forums.phpfreaks.com/topic/32409-solved-concat-function-with-separator/#findComment-150552 Share on other sites More sharing options...
artacus Posted January 1, 2007 Share Posted January 1, 2007 LOL. With a name like printf, how could he NOT know how to format strings? Link to comment https://forums.phpfreaks.com/topic/32409-solved-concat-function-with-separator/#findComment-150620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.