Timo Junolainen
Timo Junolainen

Reputation: 304

SQLite substr function in WHERE expression

Suppose I have 'employee' table with 'lname' column

I am interested in fetching all rows, where second character can be either 'e' or 'o'

What i am doing wrong, this query doesnt return anything:

SELECT * FROM employee WHERE (substr(lname,2,3)='e' OR substr(lname,2,3)='o');

Upvotes: 1

Views: 982

Answers (1)

Aducci
Aducci

Reputation: 26644

the third parameter in substr is the length, not the end character

change to substr(lname,2,1)

Upvotes: 2

Related Questions