Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the position of a character in a SQLite column?

Tags:

sql

sqlite

If the result "[email protected]" and I want to find the position of the @ symbol (3). Is it possible? It does not appear that SQLite has the equivalent of INSTR, LOCATE, POSITION or any such function.

SELECT ?('[email protected]')

Update I ended up registering a custom extension function, but was surprised that I had to.

like image 344
tofutim Avatar asked Aug 08 '11 23:08

tofutim


People also ask

What is Substr in SQLite?

The substr() function extracts and returns a substring from string . The position of the substring is determined by index and its length is determined by count . If any parameter is NULL, a NULL will be returned. Otherwise, if string is not a BLOB it will be assumed to be a text value.

What is returned by Instr (' Sqlte point Publish P ')?

Description. SQLite instr() takes a string and a substring of it as arguments, and returns an integer which indicates the position of the first occurrence of the substring within the string.

What are the three arguments for the substr () function in SQLite?

SQLite substr() returns the specified number of characters from a particular position of a given string. A string from which a substring is to be returned. An integer indicating a string position within the string X. An integer indicating a number of characters to be returned.


1 Answers

Don't know whether this is a recent addition, but the INSTR function will indeed find the 1st instance.

like image 121
mediaczar Avatar answered Oct 26 '22 14:10

mediaczar