TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL LPAD Function

Overview

In this tutorial, we will learn about MySQL LPAD Function with some examples. We can use this function to left pad with padding characters until it reaches length characters.

MySQL LPAD Function

LPAD() function returns the string with the specified characters as left padded to the original given string until it reaches the length.

Syntax

The general syntax of the function is as follows:

LPAD(<string>,<length>,<padding>)

Examples

Let’s use the function and check the output of the function in this example.

mysql> SELECT LPAD(‘MySQL’,20,’ ‘);
+———————-+
| LPAD(‘MySQL’,20,’ ‘) |
+———————-+
| MySQL |
+———————-+
1 row in set (0.00 sec)

mysql> SELECT LPAD(‘MySQL’,20,’&’);
+———————-+
| LPAD(‘MySQL’,20,’&’) |
+———————-+
| &&&&&&&&&&&&&&&MySQL |
+———————-+
1 row in set (0.00 sec)

MySQL LPAD Function

In this example, let’s use the Country database table from the world MySQL database.
The column is the Name column that contains the country name. We will left pad the column values
with the * character.

mysql> SELECT Name, LPAD(Name,25,’*’)
-> FROM Country
-> WHERE Continent=’Asia’;

 

MySQL LPAD Function Example

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL UPPER Function› MySQL SUBSTRING_INDEX Function

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version