Tranquilraven Posted December 30, 2008 Share Posted December 30, 2008 Hello everyone. I think I have a brain freeze. I am trying to use concat() in a sql querie in a PHP 6 document and it keeps throwing this exception: mysql error number: 1064, you have an error in your sql syntax. I am not seeing it. Here is the code: SELECT authors.author_id, authors.first_name, authors.family_name CONCAT(authors.first_name,' ', authors.family_name) AS author FROM authors ORDER BY authors.family_name, authors.first_name Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/138932-solved-using-concat-in-mysql-5/ Share on other sites More sharing options...
PFMaBiSmAd Posted December 30, 2008 Share Posted December 30, 2008 You need a comma after authors.family_name Quote Link to comment https://forums.phpfreaks.com/topic/138932-solved-using-concat-in-mysql-5/#findComment-726622 Share on other sites More sharing options...
Tranquilraven Posted December 31, 2008 Author Share Posted December 31, 2008 LOL. Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/138932-solved-using-concat-in-mysql-5/#findComment-726716 Share on other sites More sharing options...
fenway Posted January 2, 2009 Share Posted January 2, 2009 I prefer starting each new column from the select list on a new line with a preceding comma; also, I like CONCAT_WS(): SELECT authors.author_id , authors.first_name , authors.family_name , CONCAT_WS( ' ', authors.first_name, authors.family_name ) AS author FROM authors ORDER BY authors.family_name , authors.first_name Just my $0.02 -- IMHO, it makes it less likely to make these kinds of syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/138932-solved-using-concat-in-mysql-5/#findComment-727891 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.