
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
MySQL Function for Specified Number of Characters of a String
MySQL returns a specified number of characters of a string with the help of LEFT() and RIGHT() functions.
MySQL LEFT() function will return the specified number of characters from the left of the string.
Syntax
LEFT(str, length)
Here str is the string from which a number of characters would be returned and the length is an integer value which specifies how many characters to be returned.
Example
mysql> Select LEFT('My Name is Ram', 7); +---------------------------+ | LEFT('My Name is Ram', 7) | +---------------------------+ | My Name | +---------------------------+ 1 row in set (0.00 sec)
MySQL RIGHT() function will return the specified number of characters from the right of the string.
Syntax
RIGHT(str, length)
Here str is the string from which a number of characters would be returned and the length is an integer value which specifies how many characters to be returned.
Example
mysql> Select RIGHT('My name is Ram',6); +---------------------------+ | RIGHT('My name is Ram',6) | +---------------------------+ | is Ram | +---------------------------+ 1 row in set (0.00 sec)
Advertisements