samedi 12 septembre 2015

Error in sql Where clause equal to variable from arguments function

I want to pop a list view with 2 linked tables for this I have created the next sql:

public static Cursor ListViewTimeStudy(String passedReg) {
            // TODO Auto-generated method stub

            String sql = "SELECT "
                    + "elements._id,"
                    + "elements.idstudy,"
                    + "elements.code_element,"
                    + "times._id,"
                    + "times.idelement,"                    
                    + "times.observedtime,"
                    + "times.observedactivity"
                    + " FROM "
                    + "elements JOIN times"
                    + " ON "
                    + "elements._id = times.idelement"
                    + " WHERE "
                    + "elements.idstudy = passedReg"
                    + " ORDER BY "
                    + "times._id DESC";



            Cursor mCursor = ourDatabase.rawQuery(sql, null);

            if (mCursor != null) {
                mCursor.moveToFirst();
            }
            return mCursor;
        }

The result should show a table with fields from both tables and only the rows where elements.idstudy is equal to the variable passed in arguments of the function but in this issue I receive an error.

Aucun commentaire:

Enregistrer un commentaire