Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does SQLite say that instr doesnt exist?

Tags:

sql

sqlite

I am trying to run a query:

SELECT name
FROM Foo 
WHERE instr(name, '@') = 0 AND instr(name, '.') != 0

But I am getting the error: "no such function: instr". This confuses me because the website clearly states that the function exists. Anyone know what is going on?

P.S. I also tried the query in SQLiteSpy which gives the same error.

like image 900
chacham15 Avatar asked Jul 26 '13 17:07

chacham15


1 Answers

According to the Change History, the instr function was added in version 3.7.15:

2012-12-12 (3.7.15)

Added the instr() SQL function.

Make sure you're running the latest release.

If upgrading is not an option, you can also use the LIKE operator:

SELECT name
FROM Foo 
WHERE name NOT LIKE '%@%' -- name does NOT contain @
AND name LIKE '%.%';      -- name DOES contain .
like image 137
Mike Christensen Avatar answered Sep 28 '22 03:09

Mike Christensen