MySQL ELT() function
ELT() function
MySQL ELT() returns the string at the index number specified in the list of arguments. The first argument indicates the index of the string to be retrieved from the list of arguments.
It returns NULL when the index number is less than 1 or index number is greater than the number of the string specified as arguments.
Note: According to Wikipedia ELT stands for Extract, Load, Transform (ELT), a data manipulation process.
Syntax:
ELT(index number, string1, string2, string3,…)
Argument:
Name | Description |
---|---|
index number | An integer. |
string1, string2, string3,… | List of strings. |
MySQL Version: 5.6
Video Presentation:
Pictorial Presentation
Example: MySQL ELT() function
The following MySQL statement will return the string at 4th position from the list of strings.
Code:
SELECT ELT(4,'this','is','the','elt');
Sample Output:
mysql> SELECT ELT(4,'this','is','the','elt'); +--------------------------------+ | ELT(4,'this','is','the','elt') | +--------------------------------+ | elt | +--------------------------------+ 1 row in set (0.02 sec)
Example of MySQL ELT() function with greater index number
The following MySQL statement will return NULL because the index number is more than the number of strings.
Code:
SELECT ELT(5,'this','is','the','elt');
Sample Output:
mysql> SELECT ELT(5,'this','is','the','elt'); +--------------------------------+ | ELT(5,'this','is','the','elt') | +--------------------------------+ | NULL | +--------------------------------+ 1 row in set (0.00 sec)
Example of MySQL ELT() function with index value zero(0)
The following MySQL statement will return the NULL because the index number is less than 1.
Code:
SELECT ELT(0,'this','is','the','elt');
Sample Output:
mysql> SELECT ELT(0,'this','is','the','elt'); +--------------------------------+ | ELT(0,'this','is','the','elt') | +--------------------------------+ | NULL | +--------------------------------+ 1 row in set (0.00 sec)
All String Functions
Previous: CONCAT
Next: EXPORT_SET
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework