Android MySql query issue
I'm working on a Mysql query to search for a single row, but its throwing me some strange results, heres the simplified setup:
public Cursor cursor(String one, String two) throws SQLException
{
Cursor mCursor =
db.query(true, DATABASE_TABLE, new String[] {
KEY_ROWID,
KEY_ONE,
KEY_TWO
},
KEY_ONE + "=" + one + "; " + KEY_TWO + "=" + two,
null,
null,
null,
null,
null);
if (mCursor != null) {
mCursor.moveToFirst();
}
return mCursor;
}
Ive run this query in a loop with alternating String 2 values, the problem that occurs is that all results returned are from just one particular row from the database, even if the particular query doesn't exist with both values (I'm guessing this is a query problem?)
If I change both string 1 & 2 to something that rows on the database dont have开发者_C百科, then the cursor returns empty.
Been following this tutorial: http://www.devx.com/wireless/Article/40842/0/page/2
Cheers in advance
Your WHERE clause KEY_ONE + "=" + one + "; " + KEY_TWO + "=" + two
is wrong
Use KEY_ONE + "=" + one + " AND " + KEY_TWO + "=" + two
instead
精彩评论