Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • FIELD string function mysql

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 268
    Comment on it

    FIELD(str,str1,str2,str3,...)

    FIELD function is used to get the index (position) of str in the str1, str2, str3, ... list and it returns 0 if str is not found. In the field list if all arguments are strings then all arguments are compared as strings and If all arguments are numbers, they are compared as numbers. Otherwise, the arguments are compared as double. If str is NULL as NULL fails equality comparison with any value hence the return value will be 0. FIELD() is the complement of ELT().

    mysql> select FIELD('WORLD.','Hello','World.','How','are','you');
    +----------------------------------------------------+
    | FIELD('WORLD.','Hello','World.','How','are','you') |
    +----------------------------------------------------+
    |                                                  2 |
    +----------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> select FIELD('ho','Hello','World.','How','are','you');
    +------------------------------------------------+
    | FIELD('ho','Hello','World.','How','are','you') |
    +------------------------------------------------+
    |                                              0 |
    +------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> select FIELD('how','Hello','World.','How','are','you');
    +-------------------------------------------------+
    | FIELD('how','Hello','World.','How','are','you') |
    +-------------------------------------------------+
    |                                               3 |
    +-------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> select FIELD('','Hello','World.','How','are','you');
    +----------------------------------------------+
    | FIELD('','Hello','World.','How','are','you') |
    +----------------------------------------------+
    |                                            0 |
    +----------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> select FIELD(NULL,'Hello','World.','How','are','you');
    +------------------------------------------------+
    | FIELD(NULL,'Hello','World.','How','are','you') |
    +------------------------------------------------+
    |                                              0 |
    +------------------------------------------------+
    1 row in set (0.00 sec)
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: