安卓SQLiteException:绑定或列索引超出范围的问题绑定、索引、范围、问题

2023-09-05 05:40:44 作者:我还在原地等待iii

在Android的我现在用的是下面的语句。

In android I am using the following statement.

model = dataHelper.rawQuery("SELECT _id, engword, lower(engword) as letter FROM word WHERE letter >= 'a' AND letter < '{' AND engword LIKE '%" + filterText + "%'", new String[ {"_id","engword", "lower(engword) as letter"});

这是投掷 android.database.sqlite.SQLiteException:绑定或列索引超出范围:办理0x132330

有什么问题,我的code?

What is the problem in my code?

推荐答案

正确的说法是:

model = dataHelper.rawQuery("
    SELECT _id, engword, lower(engword) as letter
    FROM word W
    HERE letter >= 'a'
    AND letter < '{'
    AND engword LIKE ? ORDER BY engword ASC
    ",
    new String[] {"%" + filterText + "%"}
);