Home » Android » android – What is the syntax for "not equal" in SQLite?

android – What is the syntax for "not equal" in SQLite?

Posted by: admin March 11, 2020 Leave a comment

Questions:
 Cursor findNormalItems = db.query("items", columns, "type=?", 
                                   new String[] { "onSale" });

I want to return the cursor that points anything that are NOT onSale, what should I change? Thanks!

How to&Answers:

From the official documentation:

The non-equals operator can be either != or <>

So your code becomes:

Cursor findNormalItems = db.query("items", columns, "type != ?", 
                                  new String[] { "onSale" });   

Answer:

You should use in the comparator the non-equal operator:
"type!=?" or "type<>?".

Answer:

You can use <> operator

You will find here all the basic sql statements

http://www.firstsql.com/tutor2.htm