Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

MySQL Space Function

by suresh

The MySQL SPACE is one of the String Function, which returns a string consisting of specified empty space characters. The syntax behind this SPACE in MySQL is as shown below:

SPACE(Integer)

MySQL SPACE Example 1

The MySQL String Space function simply returns space charters for N number of times. The following String query shows the use of this space function.

-- STRING SPACE in MySQL example
SELECT SPACE(5);

SELECT CONCAT('Tutorial', SPACE(5), 'Gateway') AS Website;

SELECT CONCAT('Learn', SPACE(2), 'MySQL');

OUTPUT

MySQL Space Function 1

ANALYSIS

From the above MySQL screenshot, the first statement is returning empty spaces.

SELECT SPACE(5);

Well, you may not notice that empty space. So, let me concat two strings along with the space function.

SELECT CONCAT('Tutorial', SPACE(5), 'Gateway') AS Website;

MySQL SPACE Function Example 2

The String Space in MySQL also helpful for you combine (concat) multiple columns. In this example, we are going to use the space function to combine the FirstName and LastName columns. For this, We are going to use the below shown data

MySQL Space Function 2

and the String Function code is:

SELECT EmpID,
       CONCAT(FirstName, SPACE(5), LastName) AS FullName,
       Education,
       YearlyIncome,
       Sales
  FROM `mysql tutorial`.employee;

OUTPUT

MySQL Space Function 3

TIP: We used this SPACE(6) to get Six empty spaces between First Name and Last name.

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy