0

I am using a query to retrieve data from sqlite but I am getting an error.

I am using following query:

cursor = db.query ( TABLE_NAME, new String[] { EMPLOYEE }, USERID + " =  " + NAME, null, null, null, null );
1
  • Please post the error details and logcat output. Commented Mar 9, 2011 at 11:23

2 Answers 2

1
db.query(TABLE_NAME, new String[] { EMPLOYEE },USERID + " = '" + NAME + "'" , null, null, null, null);

USERID seems to be a string type. So, the value you are comparing should be surrounded by single quote

Sign up to request clarification or add additional context in comments.

Comments

0

You can also retrieve data like this .

Cursor c = null;
        c = db.rawQuery("select field from tablename where field=" + your condition, 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.