SingleStore DB

FIELD

Returns the first index of the str argument in the str1, str2, … list, or 0 if it doesn’t exist.

Syntax
FIELD (str, str1, str2, ...)
Remarks

If all arguments are strings, then all arguments are compared as strings. If all arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared as double.

If str is NULL, the return value is 0 because NULL fails equality comparison with any value.

Arguments
  • str: any string or binary object

  • str1, str2, … : list of strings or binary objects

Return Type

Integer

Example
SELECT FIELD('abra', 'cadabra', 'abra', 'abracadabra');
+-------------------------------------------------+
| FIELD('abra', 'cadabra', 'abra', 'abracadabra') |
+-------------------------------------------------+
|                                               2 |
+-------------------------------------------------+