 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we stuff a string with another one using MySQL functions?
MySQL have two functions namely LPAD() and RPAD() with the help of which we can stuff a string with another string.
LPAD() function, as the name suggests, left stuff a string with another string. Following is the syntax for using it in MySQL −
Syntax
LPAD(original_string, @length, pad_string)
Here,
- original_string is the string in which we stuff another string.
- @length is the total length of string returned after stuffing.
- Pad_string is the string which is to be stuffed with original_string.
Example
mysql> SELECT LPAD('tutorialspoint',18,'www.'); +----------------------------------+ | LPAD('tutorialspoint',18,'www.') | +----------------------------------+ | www.tutorialspoint               | +----------------------------------+ 1 row in set (0.00 sec) RPAD() function, as the name suggests, right stuff a string with another string. Following is the syntax for using it in MySQL −
Syntax
RPAD(original_string, @length, pad_string)
Here,
- original_string is the string in which we stuff another string.
- @length is the total length of string returned after stuffing.
- Pad_string is the string which is to be stuffed with original_string.
Example
mysql> SELECT RPAD('www.tutorialspoint',22,'.com'); +--------------------------------------+ | RPAD('www.tutorialspoint',22,'.com') | +--------------------------------------+ | www.tutorialspoint.com               | +--------------------------------------+ 1 row in set (0.06 sec)Advertisements
 