2

I want to select the rows that match the passed eta, category and class, attributes but that doesn't contains the passed use1 and use2 attribute, so I have written this code

public Cursor getData(String use1, String use2, String eta, String category,
            String class) {
        try {
            Cursor c;
                c = mDb.rawQuery(
                        "SELECT * FROM dbtable "
                                + "WHERE Use NOT LIKE ? AND Use NOT LIKE ? AND Eta LIKE ? AND Language LIKE ? ORDER BY Name",
                        new String[] { "%" + use1 + "%", "%" + use2 + "%", "%" + eta + "%",
                                "%" + language + "%" });
            if (c != null) {
                c.moveToNext();
            }
            return c;

        } catch (SQLException mSQLException) {
            Log.e(TAG, "getDataCar >>" + mSQLException.toString());
            throw mSQLException;
        }

    }

Unfortunately doesn't work, and doesn't exclude the rows that contains the attributes use1 and use2, if I remove the two NOT LIKE conditions, works fine... so there is a syntax error with the two NOT LIKE conditions.

4

2 に答える 2

1
WHERE Use NOT LIKE ? AND Use NOT LIKE (NOTHING HERE) AND Eta LIKE ? AND Language LIKE ? ORDER BY Name
于 2012-12-11T17:46:43.243 に答える
0

Solved, The problem is caused by a whites space in the column of database... the syntax is right.

于 2012-12-11T18:12:26.393 に答える