您好,我收到此错误:android.database.sqlite.SQLiteException:靠近“ +”语法错误(代码1),同时编译:SELECT * FROM tbl_Individual_Donor_Registration WHERE BloodGroup = B +
这是我的表元素代码:
public static final int DATABASE_VERSION = 3;
public static final String DATABASE_NAME = "BLOOD_PROJECT";
public static final String TABLE_NAME = "tbl_Individual_Donor_Registration";
public static final String TABLE_NAME_BLOOD_BANK = "tbl_Blood_Bank_Registration";
public static final String COL_1 = "Id";
public static final String COL_2 = "Name";
public static final String COL_3 = "Password";
public static final String COL_4 = "BloodGroup";
public static final String COL_5 = "BloodQuantity";
public static final String COL_6 = "MobileNo";
这里是我的实际选择查询的代码:
String select = "SELECT * FROM " + TABLE_NAME + " WHERE " + COL_4 + " = "+ final_blood_group;
并且final_blood_group来自微调值,该值来自用户的选择,希望您能帮助我,谢谢。
您需要在代码中更改一些小东西。在此处采样
正确的代码应该这样
SELECT * FROM tbl_Individual_Donor_Registration WHERE BloodGroup = 'B+'//you need single quote in B+
所以您需要在[]中加上单引号>
final_blood_group="'B+'";
然后您的代码如下所示
SELECT * FROM tbl_Individual_Donor_Registration WHERE BloodGroup ='B +'
如果您不带单身放,则作为琴键。