我使用SQLiteOpenHelper创建了一个表:
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(
"CREATE TABLE " + DATABASE_TABLE + " (" +
KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
KEY_NAME + " TEXT NOT NULL, " +
KEY_SWIMMERLAPS + " INT NOT NULL, " +
KEY_SPONSOR + " DEC NOT NULL );"
);
我如何使用SQLiteDatbase方法将赞助商的游泳圈数值乘以?
答案 0 :(得分:1)
试试这个:
Cursor cursor = db.rawQuery("SELECT " + KEY_SWIMMERLAPS + " * " + KEY_SPONSOR + " AS result FROM " + DATABASE_TABLE, null);
if (cursor.moveToFirst()){
Log.w("result", cursor.getDouble(0)+"");
}