如何通过在 SQLite 中传递产品 ID 来乘以 2 列数据?
How to multiply 2 column data by passing a product id in SQLite?
我需要乘以我的 sqlite table 中的 2 列的值。
我已经这样做了。但是我错过了传递一个特定的产品 ID 来做 multiplication.I 使用下面的代码乘以列。
public int getMultiply() {
Cursor cursor = db.rawQuery("SELECT " + DbHelper.CART_QUANTITY + " * " + DbHelper.CART_PRICE + " AS result FROM " + DbHelper.CART_TABLE, null);
if (cursor.moveToFirst()) {
Log.w("result", cursor.getDouble(0) + "");
return (int) cursor.getDouble(0);
}
return 0;
}
现在我需要通过传递 Product Id.How 以通过传递参数乘以 2 列来更正我的计算?
public int getMultiply(String PID) {.......return 0;}
只需将此添加到您的查询中:
... WHERE productID = " + PID;
我需要乘以我的 sqlite table 中的 2 列的值。 我已经这样做了。但是我错过了传递一个特定的产品 ID 来做 multiplication.I 使用下面的代码乘以列。
public int getMultiply() {
Cursor cursor = db.rawQuery("SELECT " + DbHelper.CART_QUANTITY + " * " + DbHelper.CART_PRICE + " AS result FROM " + DbHelper.CART_TABLE, null);
if (cursor.moveToFirst()) {
Log.w("result", cursor.getDouble(0) + "");
return (int) cursor.getDouble(0);
}
return 0;
}
现在我需要通过传递 Product Id.How 以通过传递参数乘以 2 列来更正我的计算?
public int getMultiply(String PID) {.......return 0;}
只需将此添加到您的查询中:
... WHERE productID = " + PID;