Mega Code Archive

 
Categories / MySQL Tutorial / String Functions
 

FIELD(str,str1,str2,str3, )

Returns 0 if str is not found. If str is NULL, the return value is 0. FIELD() is the complement of ELT(). mysql> mysql> SELECT FIELD('A', 'B', 'A', 'V', 'D', 'W'); +-------------------------------------+ | FIELD('A', 'B', 'A', 'V', 'D', 'W') | +-------------------------------------+ |                                   2 | +-------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> SELECT FIELD('Z', 'A', 'B', 'C', 'D', 'E'); +-------------------------------------+ | FIELD('Z', 'A', 'B', 'C', 'D', 'E') | +-------------------------------------+ |                                   0 | +-------------------------------------+ 1 row in set (0.02 sec) mysql>