0
Cursor cursor = db.rawQuery("SELECT id,lastname FROM people WHERE lastname=null; ",null);

this query does not return the members whose lastname is empty. What is wrong with that query ? Should I check like that WHERE lastname="" ?

3
  • have you tried lastname=''? (empty string) Commented May 21, 2012 at 19:28
  • A comment since I'm not sure exactly what you're doing: if you're trying to access the Contacts database, you should be using the built in ContentProvider classes. They're the recommended way to handle this in Android. Commented May 21, 2012 at 19:28
  • There are some simple implementations of SQL Lite for your PC. Much quicker to test and debug queries than compiling and testing you Android app... Commented May 21, 2012 at 19:33

2 Answers 2

5

Try this instead:

    ... WHERE lastname IS NULL;
Sign up to request clarification or add additional context in comments.

Comments

1

It is not possible to test for NULL values with comparison operators, such as =, <, etc.

You have to use the IS NULL and IS NOT NULL operators instead.

SELECT id, lastname FROM people WHERE lastname IS NULL;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.