vendredi 10 juillet 2015

Android SQLite query returning multiple same columns

This query below in Android Sqlite is returning multiple of the same columns. For example, it is returning "meet_id" (3) times. The first (2) "meet_id" are correct with the right number while the third one is empty. The same happens for my "athlete_id" and "event_id". I am assuming this is because of my left join since the 3rd table is empty as of now but shouldn't if just return one column for each column attribute (1 meet column and more rows?):

Cursor cursorTemp = db.rawQuery("SELECT * FROM " + TABLE_MEETS + " LEFT JOIN " + TABLE_MEETS_ATHLETES +
                " ON " + TABLE_MEETS + "." + COL_MEET_ID + " = " + TABLE_MEETS_ATHLETES + "." + COL_MEET_ID +
                " LEFT JOIN " + TABLE_MEETS_ATHLETES_SPLITS + " ON " + TABLE_MEETS_ATHLETES + "." + COL_MEET_ID +
                " = " + TABLE_MEETS_ATHLETES_SPLITS + "." + COL_MEET_ID + " AND " + TABLE_MEETS_ATHLETES +
                "." + COL_ATHLETE_ID + " = " + TABLE_MEETS_ATHLETES_SPLITS + "." + COL_ATHLETE_ID + " AND " +
                TABLE_MEETS_ATHLETES + "." + COL_EVENT_ID + " = " + TABLE_MEETS_ATHLETES_SPLITS + "." +
                COL_EVENT_ID + " WHERE " + TABLE_MEETS + "." + COL_MEET_ID + " = ?", new String[]{String.valueOf(i)});

I understand this is a bit messy but I like raw queries more

Also, meet id is a primary key in the first table and composite in 2nd and 3rd

Aucun commentaire:

Enregistrer un commentaire