MySQL Tutorial/String Functions/FIELD
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>