FIELD
Return the index of a string in a list. This function returns the position of the first argument within the subsequent list of arguments.
Syntax
FIELD(pattern, str1[,str2,...])Description
Examples
SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo')
AS 'Field Results';
+---------------+
| Field Results |
+---------------+
| 2 |
+---------------+
SELECT FIELD('fo', 'Hej', 'ej', 'Heja', 'hej', 'foo')
AS 'Field Results';
+---------------+
| Field Results |
+---------------+
| 0 |
+---------------+
SELECT FIELD(1, 2, 3, 4, 5, 1) AS 'Field Results';
+---------------+
| Field Results |
+---------------+
| 5 |
+---------------+
SELECT FIELD(NULL, 2, 3) AS 'Field Results';
+---------------+
| Field Results |
+---------------+
| 0 |
+---------------+
SELECT FIELD('fail') AS 'Field Results';
Error 1582 (42000): Incorrect parameter count in call
to native function 'field'See also
Last updated
Was this helpful?

