Mysql Space Function

MySQL: SPACE Function

This tutorial explains how to use the MySQL SPACE function with syntax and examples.


The MySQL SPACE function returns a string with a specified number of spaces.


The syntax for the SPACE function in MySQL is:

SPACE( number )

Parameters or Arguments


The number of spaces to be returned.

Applies To

The SPACE function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0, MySQL 3.23


Let's look at some MySQL SPACE function examples and explore how to use the SPACE function in MySQL.

For example:

mysql> SELECT SPACE(3);
Output: '   '

mysql> SELECT SPACE(7);
Output: '       '