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 :
Similar Reads
FIELD() function in MySQL FIELD() : This function helps in returning the position of a value in the given value list. If the user passes string values as the argument of FIELD() function, then the search will be performed as string values. And, If the user passes numeric values as the argument of FIELD() function, then searc
2 min read
COT() Function in MySQL COT() function : This function in MySQL is used to return the cotangent of a specified number. If the specified number is 0, an error or NULL will be returned. In a right triangle, the cotangent of an angle is the length of it's adjacent side divided by the length of the opposite side. Similarly, th
1 min read
EXP() Function in MySQL EXP() function in MySQL is used to returns E raised to the power of a specified number. Here E(2.718281...) is the base of the natural logarithm. Syntax : EXP(X) Parameter : This method accepts one parameter as mentioned above in the syntax and described below : X â A specified number which will be
2 min read
CEILING() Function in MySQL CEILING() function :This function in MySQL is used to return the smallest integer value that is greater than or equal to a specified number. For example, if the specified number is 4.6, this function will return the integer value of 5 that is greater than 4.6 or if a specified number is 5, this func
2 min read
EXTRACT() Function in MySQL The EXTRACT() function in MySQL is a versatile tool used for retrieving specific components of date Whether we need the year, month, day or even the hour or minute. This function simplifies date manipulation and makes queries involving date and time data more efficient and easier to understand. In t
3 min read