我在rawQuery上遇到错误,我试图加入两个表?
SELECT Calories FROM CalorieIntake_Table c INNER JOIN Users_Table u ON c.USER_ID = u.U_IDWHERE u.U_ID =?
以下是查询的代码:
public CalorieIntake getuserIntake(int id) {
CalorieIntake calorieIntake = null;
SQLiteDatabase db = getReadableDatabase();
final String UserintQuery = "SELECT " + KEY_CALORIES + " FROM "
+ TABLE_CALORIE_INTAKE + " c " + " INNER JOIN " + TABLE_USERS + " u " +
"ON" + " c." + KEY_USER_ID + " = u." + KEY_U_ID + "WHERE u." + KEY_U_ID + " =?";
Cursor cursor = db.rawQuery(UserintQuery, new String[]{String.valueOf(id)});
if (cursor != null && cursor.getCount() > 0) {
cursor.moveToFirst();
calorieIntake = new CalorieIntake(cursor.getInt(0), cursor.getString(1), cursor.getDouble(2));
}
return calorieIntake;
}