Jump to content

[SOLVED] using CONCAT() in mysql 5


Tranquilraven

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.