
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- In MySQL, how can we pad a string with another string?
- How can we calculate the Date in MySQL using functions?
- How can we combine functions in MySQL?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How can we replace all the occurrences of a substring with another substring within a string in MySQL?
- What MySQL functions can we use to change the character case of a string?
- In MySQL, how can we check whether a string of a specified pattern is not present within another string?
- How can we distinguish between MySQL IFNULL() and NULLIF() functions?
- How can we use group functions with non-group fields in MySQL SELECT query?
- In MySQL, how can we use FROM_UNIXTIME() function with format string?
- How can we copy one array from another in Java
- How can we create a MySQL view based on another existing view?
- What are MySQL stored functions and how can we create them?
- How we can copy Python modules from one system to another?
- Replace one string with another string with Java Regular Expressions

Advertisements