Michael Haas
Michael Haas

Reputation: 103

Select elements with between between not work in SQLite

Following table contains my SQLite-Database on Android:

 >>>>> Dumping cursor android.database.sqlite.SQLiteCursor@9f3d273
0 {
   id=1543948972569
   relationItemID=-1
   degree=-1
}
1 {
   id=-1
   relationItemID=1543948972569
   degree=1
}
2 {
   id=1543948972569
   relationItemID=1543948978808
   degree=1
}
3 {
   id=1543948978808
   relationItemID=1543948972569
   degree=-1
}
<<<<<

The SQLite-Query

SELECT id FROM itemsHierarchy 
WHERE id = 1543948972569 AND degree BETWEEN 0 AND -128

Returns an empty cursor even though it should find id of first entry. But if I use '<' instead of 'BETWEEN 0 AND -128' like below, it works.

SELECT id FROM itemsHierarchy WHERE id = 1543948972569 AND degree < 0;

Did I do something wrong or is it a problem of SQLite?

Upvotes: 0

Views: 157

Answers (1)

Gaurav
Gaurav

Reputation: 623

It should be -

    SELECT id 
    FROM itemsHierarchy 
    WHERE id = 1543948972569 
    AND degree BETWEEN -128 AND 0

Upvotes: 2

Related Questions