SPACE() - Repeating Space Character

Q

How to repeat a space character for multiple times using the SPACE() function?

✍: FYIcenter.com

A

SPACE(N) is a MySQL built-in function that returns a string of multiple space characters. For example:

SELECT CONCAT('WWII ended in (', SPACE(4), ')');
  -- +------------------------------------------+
  -- | CONCAT('WWII ended in (', SPACE(4), ')') |
  -- +------------------------------------------+
  -- | WWII ended in (    )                     |
  -- +------------------------------------------+

Reference information of the SPACE() function:

SPACE(N): str
  Returns a string consisting of N space characters, or NULL
  if N is NULL.

Arguments, return value and availability:
  N: Required. The number of space characters in returning string.
  str: Return value. The string of N space characters.
  Available since MySQL 4.0.

 

STRCMP() - Comparing Strings

SOUNDEX() - Soundex Encoding

MySQL Functions on Character String Values

⇑⇑ MySQL Function References

2023-11-13, 231🔥, 0💬