in ORMLite document i can not find any document about this SQL command:
SELECT * FROM table WHERE state <> 1
i can get query where equal by this code:
List<ContactLists> contacts = G.CONTACTLISTSDAO.queryForEq("state","1");
how to change this code to NOT Equal
how to change this code to NOT Equal
The ORMLite DAO has a simple queryForEq(...)
method. If you look at the code for queryForEq(...)
you will see that it is just a convenience method for:
return queryBuilder().where().eq(fieldName, value).query();
This means that you can change the where to use ne(...)
instead of eq(...)
:
return queryBuilder().where().ne(fieldName, value).query();
To do more complex queries you should RTFM about the QueryBuilder
.
The QueryBuilder
uses the where()
method and Where
class to define the WHERE
portions of the query. There is eq
for equals, gt
for greater-than, lt
for less-than, ne
for not-equals, etc.. So, as @BrownKang points out, your query would be something like:
List<ContactLists> contacts =
G.CONTACTLISTSDAO.queryBuilder().where().ne("state", "1").query();