FIELD()
FIELD() is a SQL function in the String Functions category. Returns the index (1-based) of value in a list. MySQL-specific. Returns 0 if not found. The syntax is FIELD(value, val1, val2, val3, ...). It accepts value, val1, val2, val3, .... It returns index integer. A typical example: SELECT FIELD('c', 'a', 'b', 'c', 'd'); -- 3 -- Useful for custom sort order: SELECT name, priority FROM tasks ORDER BY FIELD(priority, 'High', 'Medium', 'Low'); A close relative is CONCAT(), which concatenates two or more strings into one string. Returns NULL if any argument is NULL. A close relative is SUBSTRING(), which extracts characters from a string starting at position `start` for `length` characters. A close relative is REPLACE(), which replaces all occurrences of `from_string` with `to_string` in a string. More about this category: String manipulation — CONCAT, SUBSTRING, REPLACE, TRIM, UPPER, LOWER, LENGTH. Related String Functions entries: CONCAT(), SUBSTRING(), REPLACE(), LENGTH(), TRIM(), UPPER(), LOWER(), LPAD() / RPAD().