Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a boolean in an SQLite WHERE clause

Tags:

android

sqlite

I get no results. How can I include a boolean conditional in a where clause in SQLite?

I have tried these

"Select * from table where col = 1"
"Select * from table where col = '1'"
"Select * from table where col = true"
"Select * from table where col = 'true'"
"Select * from table where col = 'True'"
"Select * from table where col is True"

Nothing. I even tried including "true" as the whereArgs in a query function.

How can I fix it?

like image 779
Jonathan S. Avatar asked Jan 28 '11 03:01

Jonathan S.


1 Answers

SQLite does not have a separate Boolean storage class. Instead, Boolean values are stored as integers 0 (false) and 1 (true).

Source: SQLite

The first one then sounds correct.

like image 200
seppo0010 Avatar answered Oct 04 '22 17:10

seppo0010