Insert space between arguments to concat function

You can concatenate string literals along with your fields, so you can add a space character in a string between the fields you’re concatenating.

Use this:

 CONCAT(name, " ", surname)

This functionality is documented quite clearly on the MySQL manual page for the CONCAT() function.

There is also the CONCAT_WS function which allows you to specify a separator to be used between each of the other fields passed to the function. If you’re concatenating more than two fields in the same way, this function might be considered cleaner than repeating the separator between each field.

For example, if you wanted to add a middle name field, you could use this function to specify the separator only once:

CONCAT_WS(" ", first_name, middle_name, surname)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)