Name

SPACE( )

Synopsis

SPACE(count)

This function returns a string of spaces. The number of spaces returned is set by the argument.

SELECT CONCAT(name_first, SPACE(1), name_last)
AS Name
FROM students LIMIT 1;
+------------------+
| Name             |
+------------------+
| Richard Stringer |
+------------------+

Although this requires more typing than just placing a space within quotes, it’s more visible to a human reader. Also, you could substitute the count with a variable in a program, and adjust it for the length of the name or some other factor.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.