May 16, 2021 SQL
SQL FIELD() function instance code tutorial
The FIELD() function returns the str of the index (where it started from 1) in str1, str2, str3,... l ist. If str is not found, 0 is returned.
The returned index (where it starts from 1) str is in str1, str2, str3,... l ist. If str is not found, 0 is returned.
The string "ej" was found in the second position.
SQL> SELECT FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
+---------------------------------------------------------+
| FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo') |
+---------------------------------------------------------+
| 2 |
+---------------------------------------------------------+
1 row in set (0.00 sec)