FIELD
Syntax
FIELD(str,str1,str2,str3,...)
Description
Returns the index position of the str parameter in the str1, str2, str3,... list, starting from 1. If str is not found, the return value is 0.
If all parameters of FIELD() are strings, all parameters are compared as strings. If all parameters are numbers, they are compared as numbers. Otherwise, all parameters are compared as DOUBLE values.
If str is NULL, the return value is 0, because NULL cannot be compared to any value. FIELD() is the inverse of ELT().
Examples
SELECT FIELD('abc','abc1','abc2','abc','abc4','abc'), FIELD(NULL, 'null1', NULL);
+-----------------------------------------------+----------------------------+
| FIELD('abc','abc1','abc2','abc','abc4','abc') | FIELD(NULL, 'null1', NULL) |
+-----------------------------------------------+----------------------------+
| 3 | 0 |
+-----------------------------------------------+----------------------------+
1 row in set (0.001 sec)