
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
What happens if the length of the original string is greater than the length of the string returned after padding in LPAD() or RPAD() functions?
In this case, MySQL will not pad anything and truncate the characters from the original string up to the value of length provided as the argument in LPAD() or RPAD() functions.
Example
mysql> Select LPAD('ABCD',3,'*'); +--------------------+ | LPAD('ABCD',3,'*') | +--------------------+ | ABC | +--------------------+ 1 row in set (0.00 sec) mysql> Select RPAD('ABCD',3,'*'); +--------------------+ | RPAD('ABCD',3,'*') | +--------------------+ | ABC | +--------------------+ 1 row in set (0.00 sec)
We can observe from the above example that both the functions do not pad ‘*’ and truncate the original string up to the length specified i.e. 3 as the argument.
- Related Questions & Answers
- What MySQL returns, if the length of the original string is greater than the length specified as an argument in LPAD() or RPAD() functions?
- How can we use MySQL LPAD() and RPAD() functions in the same query for padding the string to both sides, left and right, of the original string?
- What MySQL returns if we provide an empty string for padding with other string in LPAD() or RPAD() functions?
- Check if the frequency of any character is more than half the length of the string in Python
- What is the maximum length of string in Python?
- What is the max length of a Python string?
- How can we use LPAD() or RPAD() functions with the values in the column of a MySQL table?
- How MySQL LENGTH() function measures the string length?
- How to calculate the length of the string using C#?
- Find the Length of the Longest possible palindrome string JavaScript
- What happens if the substring is there for more than one time in the string given as the arguments of LOCATE() function?
- Python - Find the length of the last word in a string
- Display substring in MySQL if the string is less than a specific length or display a custom message if it is more?
- C++ Program to Find the Length of a String
- C program to find the length of a string?
Advertisements