选择两个或多个列的查询错误android

时间:2018-04-03 02:08:28

标签: android sqlite

String username= edit_username.getText().toString();
String password=edit_password.getText().toString();
cursor=sqLiteDatabase.rawQuery("SELECT*FROM "+DatabaseHelper.TABLE_NAME+ " WHERE "  + DatabaseHelper.col_4+ "= AND"+DatabaseHelper.col_5+"",
                    new String[]{username,password});

显示错误和等号的位置

2 个答案:

答案 0 :(得分:1)

由于您使用的是selectionArgs,因此缺少问号。尝试更改此行

DatabaseHelper.col_4+ "= ? AND "+ DatabaseHelper.col_5+"=?"

答案 1 :(得分:0)

"SELECT * FROM "+DatabaseHelper.TABLE_NAME+ " WHERE "  + DatabaseHelper.col_4+ "= AND"+DatabaseHelper.col_5+""

我猜你错过了什么。 我们假设TABLE_NAME =“Person”, col_4 = name,col_5 = age

SELECT * FROM Person WHERE name = AND age

你不应该添加像name =“John”和age = 20这样的参数吗?