Field() functions search for the specified string in the strings arguments. If the search string is found then its index position will be returned else 0 will be returned.
If all arguments are strings, all arguments are compared as strings.
If all arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared as double.
If searchString is NULL, the return value is 0 because NULL fails equality comparison with any value.
[table caption=”” width=”100%” colwidth=”15%|30%|55%” colalign=”left|left|left”]
Name, Required /Optional, Description
searchString, Required, The search string in the list.
string1, Required, It is must.
string2 , Optional, It is optional.
string3 , Optional, It is optional.
[/table]
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Returns,
index (position), It returns index position of searchString in the list.
0, if search string is not found.
0, If search string is NULL.
[/table]
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 4.0
[/table]
mysql> SELECT FIELD('.net','Tutorial', 'mines', '.net') ; +--------------------------------------------+ | FIELD('.net','Tutorial', 'mines', '.net') | +--------------------------------------------+ | 3 | +--------------------------------------------+ 1 row in set (0.00 sec)
mysql> SELECT FIELD('www','Tutorial', 'mines', '.net') ; +------------------------------------+ | FIELD('www','Tutorial', 'mines', '.net') | +------------------------------------+ | 0 | +------------------------------------+
mysql> SELECT FIELD('.net','11', '22', '33') ; +------------------------------------+ | FIELD('.net','11', '22', '33') ; | +------------------------------------+ | 0 | +------------------------------------+
mysql> SELECT FIELD('NULL','11', '22', '33') ; +------------------------------------+ | FIELD('NULL','11', '22', '33') ; | +------------------------------------+ | 0 | +------------------------------------+
mysql> SELECT FIELD(22, 11, 22, 33) ; +------------------------------------+ | FIELD(22, 11, 22, 33) ; | +------------------------------------+ | 2 | +------------------------------------+
mysql> SELECT FIELD('6','') ; +------------------------------------+ | FIELD('6','') | +------------------------------------+ | 0 | +------------------------------------+
See all MySQL String functions MySQL 8 String Functions.
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…