Android Select查询包含两个参数

时间:2011-12-13 09:35:38

标签: android sql

有谁知道如何使这项工作,我从来没有尝试过,所以我不知道从哪里开始。调用代码很高兴发送两个参数,但查询不满意并要我删除+“AND BeachFK =?”,args2

public String getFacilityDetail(String F_ID, String B_ID) {
    String[] args1 = {F_ID};
    String[] args2 = {B_ID};

    Cursor c = getReadableDatabase().rawQuery("SELECT FacilityDescription FROM BeachFacility WHERE FacilityFK=?", args1 + " AND BeachFK=?", args2);
    if(c.moveToNext()){
        return(c.getString(c.getColumnIndex("FacilityDescription")));
    }
    c.close();
    return F_ID;
}

任何帮助将不胜感激!

干杯,

麦克

1 个答案:

答案 0 :(得分:1)

您有两种方式:

rawQuery("SELECT FacilityDescription FROM BeachFacility WHERE FacilityFK=? AND BeachFK=?",new String[]{F_ID, B_ID});

或:

rawQuery("SELECT FacilityDescription FROM BeachFacility WHERE FacilityFK='" + F_ID + "' AND BeachFK='" + B_ID + "'", null);