android.database.sqlite.SQLiteException: near ")": syntax error (code 1):
android.database.sqlite.SQLiteException: near ")": syntax error (code 1):
public String getProductName(double id) {
database = DBHelper.getReadableDatabase(); // open database to perform some operation
Cursor c = database.rawQuery("SELECT " + COL_PRODUCT_NAME + " FROM "
+ TABLE_PRODUCT + " WHERE " + COL_CATEGORY + "= " + id +" ", null);
if(c.moveToFirst())
{
String strCatName = c.getString(c.getColumnIndex(COL_PRODUCT_NAME));
c.close();
database.close();
return strCatName;
}
else
{
return "";
}
}
public String getProductName(double id) {
database = DBHelper.getReadableDatabase(); // open database to perform some operation
Cursor c = database.rawQuery("SELECT " + COL_PRODUCT_NAME + " FROM "
+ TABLE_PRODUCT + " WHERE " + COL_CATEGORY + "= " + id +" ", null);
if(c.moveToFirst())
{
String strCatName = c.getString(c.getColumnIndex(COL_PRODUCT_NAME));
c.close();
database.close();
return strCatName;
}
else
{
return "";
}
}
Here's the problem :
07-14 16:51:15.683: E/AndroidRuntime(1497): Caused by: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: SELECT COUNT(*) FROM table_product WHERE category = '3')