Jump to: navigation, search

Mysql ELT

From w3cyberlearnings

Contents

MySQL ELT Function

This function returns string base on the N number. Number is an index of the function argument. The index is started from 1 onward.

Syntax ELT

  • N is the return of the string (N=1 then return Str1, N=2 then return Str2,..)
  • Str1: Index 1 of the string
  • Str2: Index 2 of the string
ELT(N,Str1, Str2, Str3,...);

Example 1

mysql> SELECT ELT(1,'mit','standord','banana','apple');
+------------------------------------------+
| ELT(1,'mit','standord','banana','apple') |
+------------------------------------------+
| mit                                      |
+------------------------------------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT ELT(2,'mit','standord','banana','apple');
+------------------------------------------+
| ELT(2,'mit','standord','banana','apple') |
+------------------------------------------+
| standord                                 |
+------------------------------------------+
1 row in set (0.00 sec)

Example 3

mysql> SELECT ELT(4,'a','b','c','d','e','f');
+--------------------------------+
| ELT(4,'a','b','c','d','e','f') |
+--------------------------------+
| d                              |
+--------------------------------+
1 row in set (0.00 sec)

Related Links


Navigation
Web
SQL
MISC
References