Syntax
LOCATE ( characterExpression, characterExpression [ , startPosition ] )
There are two required arguments to the LOCATE function,
and a third optional argument.
- The first characterExpression specifies the string to
search for.
- The second characterExpression specifies
the string in which to search.
- The third argument is the startPosition, which specifies
the position in the second argument at which the search is
to start. If the third argument is not provided, the LOCATE
function starts its search at the beginning of the second
argument.
The return type for LOCATE is an integer. The LOCATE function
returns an integer indicating the index position within the
second argument at which the first argument was first located. Index
positions start with 1.
If the first argument is not found in the second argument, LOCATE
returns 0. If the first argument is an empty string (''), LOCATE
returns the value of the third argument (or 1 if it was not provided),
even if the second argument is also an empty string. If a NULL
value is passed for either of the characterExpression arguments,
NULL is returned.