This SQLite post explains how to use the SQLite instr function with syntax and examples.
The SQLite instr function returns the location of a substring in a string.
The syntax for the instr function in SQLite is:
The string to search.
The substring to search for in string.
The instr function can be used in the following versions of SQLite:
Let's look at some SQLite instr function examples and explore how to use the instr function in SQLite.
For example:
Question: I've tried to use the instr function in SQLite but it returns the error:
I know that the function exists, what do I do?
Answer: The instr function was first introduced in SQLite 3.7.15 so you must be running an older version of SQLite. Not sure what version of SQLite you are running, try the sqlite_version function.
Now that you know that your version of SQLite is older and does not support the instr function, you can either upgrade your version of SQLite to something newer or try rewriting your SQL statement without the instr function, possibly with the LIKE condition.
For example, if you had tried to run the following SQL statement using the instr function:
You could try rewriting the statement using the LIKE condition as follows:
These two statements would return the same results.