ELT() Function in MySQL
In this article, we are going to cover ELT function with examples. In ELT function, number field will state that how many strings will be there.
ELT function in MySQL is used to returns the string which is at index number specified in the argument list. In this function there is number field and strings field.
Syntax :
ELT(N, string1, string2, string3, string4, …)
Parameter :
This method accepts two parameter as mentioned above and described below.
- N : It is an integer and it is the index of the string to be retrieved.
- string1, string2, string3 : List of strings from which we want retrieve.
Returns –
It returns a string at the specified index . It returns NULL, if there is no string at specified index N.
Example-1 :
Retrieving a string using ELT() function.
Select ELT(4, 'Learning', 'SQL', 'at', 'w3wiki', 'is', 'fun') As Res_Str;
Output :
Res_Str |
---|
w3wiki |
Example-2 :
Retrieving a string using ELT() function.
Select ELT(1, 'Learning', 'SQL', 'at', 'w3wiki', 'is', 'fun') As Res_Str;
Output :
Res_Str |
---|
Learning |
Example-3 :
Retrieving a string using ELT() function when there is no string at specified index.
Select ELT(8, 'Learning', 'SQL', 'at', 'w3wiki', 'is', 'fun') As Res_Str;
Output :
Res_Str |
---|
NULL |
Contact Us