johnmary
johnmary

Reputation: 11

Can't use BETWEEN or more than two comparison operators in sqlite

The sqlite database has a column called reference with values like 001234567800000002 and 001234567800000019.

However, when I do the query "SELECT reference FROM table WHERE reference BETWEEN 001234567800000002 AND 001234567900000001", I get nothing in response, when I should get those two forementioned values.

I get nothing as well when I do the query "SELECT reference FROM table WHERE reference > 001234567800000002 AND reference < 001234567900000001". I do, however, get those two values when I do the query "SELECT reference FROM table WHERE reference < 001234567900000001" or just "SELECT reference FROM table WHERE reference > 001234567800000002", getting those two values.

Why can't I query with those two operators between this range? The values stored in that column are like "001234567800000002",with the type TEXT.

Thanks for the attention

Upvotes: 0

Views: 127

Answers (2)

johnmary
johnmary

Reputation: 11

The solution was just quoting the range values in BETWEEN or the greater/lesser than when I used both operators. It was weird considering it worked if I just used one operator, but it works. kudos to @Michael Berkowski in the answer

Upvotes: 1

Interface
Interface

Reputation: 342

Just change the type of the column to a numeric type like bigint

Upvotes: 0

Related Questions