ELT() Function in MySQL
Last Updated :
24 Sep, 2020
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', 'geeksforgeeks', 'is', 'fun')
As Res_Str;
Output :
Example-2 :
Retrieving a string using ELT() function.
Select ELT(1, 'Learning', 'SQL', 'at', 'geeksforgeeks', 'is', 'fun')
As Res_Str;
Output :
Example-3 :
Retrieving a string using ELT() function when there is no string at specified index.
Select ELT(8, 'Learning', 'SQL', 'at', 'geeksforgeeks', 'is', 'fun')
As Res_Str;
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...