I used SQLite on Android for a long time, but for the first time I performed the join-table operation. I am completely upset about this because I have been working on it all day.
Now I have 2 tables, FTSProfile and FTSCell, and I want to join them using the shared key A with LEFT JOIN. So I implemented a series of ContentProvider and Database code to accomplish what I want. In the database, I used SQLiteQueryBuilder to build the query and therefore get the cursor that I want. I used:
SQLiteQueryBuilder builder = new SQLiteQueryBuilder(); builder.setTables(FTS_VIRTUAL_TABLE_PROFILE+" LEFT JOIN "+FTS_VIRTUAL_TABLE_CELL+" ON "+FTS_VIRTUAL_TABLE_CELL+"."+Database.KEY_CID+"="+FTS_VIRTUAL_TABLE_PROFILE+"."+Database.KEY_CELL_ID); builder.setProjectionMap(mColumnMap_CombinedTable);
and my hashmap looks like:
HashMap<String,String> map = new HashMap<String,String>(); for (String key: KEYS_PROFILE) map.put(key, FTS_VIRTUAL_TABLE_PROFILE+"."+key); for (String key: KEYS_CELL) map.put(key, FTS_VIRTUAL_TABLE_CELL+"."+key); map.put(BaseColumns._ID, BaseColumns._ID); map.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID, "rowid AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA_ID); map.put(SearchManager.SUGGEST_COLUMN_SHORTCUT_ID, "rowid AS " + SearchManager.SUGGEST_COLUMN_SHORTCUT_ID);
And then, when I run the program and try to open the list for the result, I get SQLiteException: no such column: _id...
I have no idea how to solve it, but I really want to know how I can get rid of it. Can anyone help?
source share