What happens if you switch the last two arguments? INSTR('she sells seashells','s',3,2) Note that regardless of the starting position (or, as described below, the direction of the search), the position returned by INSTR and the other string-index search functions described here is always based on the substring’s position in the string itself, starting at the beginning of the string, and not its position in relation to the start or direction of the search. It would skip the “s” in “she” (because it’s in position 1), and return 11, the position of the first “s” in “seashells”. This tells Oracle SQL to look for the third instance of “s” starting from position 2.
The basic two-argument version of INSTR is common to both Oracle SQL and MySQL, but in Oracle SQL, you can optionally use two other arguments - the starting position, and which occurrence of the string you’re looking for, like this: INSTR('she sells seashells','s',2,3) Note that if INSTR does not find the substring, it returns the number 0 (zero).
In an actual SQL query, you might use it like this: SELECT INSTR (Fruit, 'berry') This means that if you tell INSTR to look for “berry” in “strawberry” it will return 6, because “berry” starts at position 6 in “strawberry”: INSTR('strawberry','berry') INSTR searches for a substring within a string and returns its starting location in the string, using the syntax INSTR(string,substring). To find out more about SQL, you might want to check out some of the online classes that help you master Master MySQL. It’s worth you while to get acquainted with basic SQL functions such as INSTR, since SQL programming is a skill that’s in high demand.
It is used by Oracle SQL and MySQL many other SQL implementations have functions which are the exact or near equivalent. The SQL INSTR function allows you to find the starting location of a substring within a string.