Skip to content Skip to sidebar Skip to footer

Raw Query With Multiple Parameters

PREF_NAME, PREF_STATUS - text It gives me this error: 07-02 14:08:07.457: E/AndroidRuntime(17295): android.database.sqlite.SQLiteException: near '?': syntax error: , while compilin

Solution 1:

According with the documentation, you only can put "?" on where clause:

public Cursor rawQuery (String sql, String[] selectionArgs)

Parameters
sql the SQL query. The SQL string must not be ; terminated
selectionArgs   You may include ?s inwhere clause in the query, which will be replaced by the valuesfrom selectionArgs. The values will be bound as Strings.

Solution 2:

After the SELECT keyword you have a ? instead of something like *.

Solution 3:

I guess you wanted to pass assigned_pref_name as a string and not variable name so :

Cursorc= db.rawQuery(
              "SELECT ? FROM ? WHERE ? = ?",
                newString[]{
                PREF_STATUS,
                PREF_TABLE,
                PREF_NAME, 
                "assigned_pref_name"//as a string 
          });

Post a Comment for "Raw Query With Multiple Parameters"