Return the index position of "q" in the string list:
SELECT FIELD("q", "s", "q", "l");
Try it Yourself »
The FIELD() function returns the index position of a value in a list of values.
This function performs a case-insensitive search.
Note: If the specified value is not found in the list of values, this function will return 0. If value is NULL, this function will return 0.
FIELD(
value,
val1,
val2,
val3, ...)
Parameter | Description |
---|---|
value | Required. The value to search for in the list |
val1, val2, val3, .... | Required. The list of values to search |
Works in: | From MySQL 4.0 |
---|
Return the index position of "c" in the string list:
SELECT FIELD("c", "a", "b");
Try it Yourself »
Return the index position of "Q" in the string list:
SELECT FIELD("Q", "s", "q", "l");
Try it Yourself »
Return the index position of 5 in the numeric list:
SELECT FIELD(5, 0, 1, 2, 3, 4, 5);
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!