
- 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
Which MySQL function returns a specified number of characters of a string as output?
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)
- Related Articles
- Which function in MySQL returns the same output as BIN() function?
- When MySQL FIND_IN_SET() function returns NULL as output?
- When MySQL LOCATE() function returns NULL as the output?
- When MySQL SUBSTRING_INDEX() function returns the same string, provided in the argument, as output?
- What MySQL INSERT() function returns if the number of characters to be removed exceeds the number of characters available in original string?
- What MySQL returns if specified format string is not as per accordance with the date string passed as arguments to STR_TO_DATE() function?
- How to replicate a string for a specified number of times in MySQL?
- What MySQL returns if I provide a non-hexadecimal number as an argument to UNHEX() function?
- What MySQL returns on passing an invalid string as an argument to STR_TO_DATE() function?
- What MySQL ELT() function returns if the index number, provided as an argument, is higher than the number of strings?
- How can we check that by default MySQL CHAR() function returns a binary string?
- What MySQL returns if the search string is not in the list of strings provided as argument in FIELD() function?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- What MySQL returns if we pass column name, containing a NULL value, as one of the arguments of CONCAT() function?
- What MySQL returns, if the length of the original string is greater than the length specified as an argument in LPAD() or RPAD() functions?

Advertisements