MySQL Tutorial/String Functions/FIELD — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 13:44, 26 мая 2010

FIELD(str,str1,str2,str3,...): Returns the index (position) of str in the str1, str2, str3, ... list

Returns 0 if str is not found.

If str is NULL, the return value is 0.

FIELD() is the complement of ELT().



mysql>
mysql> SELECT FIELD("A", "B", "A", "V", "D", "W");
+-------------------------------------+
| FIELD("A", "B", "A", "V", "D", "W") |
+-------------------------------------+
|                                   2 |
+-------------------------------------+
1 row in set (0.00 sec)
mysql>
mysql>
mysql> SELECT FIELD("Z", "A", "B", "C", "D", "E");
+-------------------------------------+
| FIELD("Z", "A", "B", "C", "D", "E") |
+-------------------------------------+
|                                   0 |
+-------------------------------------+
1 row in set (0.02 sec)
mysql>