Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • LOCATE(substr,str)/LOCATE(substr,str,pos) function mysql

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 340
    Comment on it

    LOCATE(substr,str), LOCATE(substr,str,pos)

    LOCATE function returns the position of first occurrence substring in passed string. The second syntax returns the first occurrence of substring after the given position (the thirds parameter of second syntax). It returns 0 if the substr is not in string.

    Here are some example which will explain these above 2 functions-

    mysql> SELECT LOCATE('bar', 'foobarbar');
            -> 4
    
    mysql> SELECT LOCATE('xbar', 'foobar');
            -> 0
    
    mysql> SELECT LOCATE('bar', 'foobarbar', 5);
            -> 7
    

 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: