Issue
I am checking both the password and email enter by the user is exist in the database or not
String queryEmail="SELECT * FROM " + TABLE_NAME + " WHERE " + col_2 + " = " +email+ " WHERE " + col_3 + "=" +password;
Cursor cr=db.rawQuery(queryEmail,null);
if(cr.moveToFirst())
{
return true;
}
else
return false;
ERROR:
Process: com.hfad.projectwithsql, PID: 4782
android.database.sqlite.SQLiteException: near "WHERE": syntax error (code 1): , while compiling: SELECT * FROM Employee WHERE EMPLOYEE_EMAIL = 12 WHERE EMPLOYEE_PASSWORD=1234
Solution
For having multiple conditions in where
clause you need to use AND
, replace
" WHERE " + col_2 + " = " +email+ " WHERE " + col_3 + "=" +password;
With where col2=email AND col3=password
(with correct formatting of course
here is a link to help you understand better Multiple Conditions in Where Clause also explains how to use AND
& OR
(multiple conditions in where clause)
Answered By - MoonLight
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.