title: Android SQLite Query
body: <p>I got the following 2 tables in my app's database</p>
  
  <p>Table1:</p>
  
  <pre><code>FTSProfile
  -----------
  suggest_intent_data_id
  suggest_shortcut_id
  CELL_ID
  NAME
  _id
  </code></pre>
  
  <p>Table2:</p>
  
  <pre><code>FTSCell
  -----------
  suggest_intent_data_id
  KEY_LAC
  suggest_shortcut_id
  _id
  KEY_MCC
  KEY_CID
  KEY_MCC
  </code></pre>
  
  <p>And I want to perform a left join on the tables, with KEY_CID = KEY_CELL_ID. Every thing seems fine until i want to get the FTSCell._id and cast it as _ID in the resultant table. I used the SQLiteQueryBuilder to help building the query:</p>
  
  <pre><code>SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
      builder.setTables(FTS_VIRTUAL_TABLE_PROFILE+" LEFT JOIN "+FTS_VIRTUAL_TABLE_CELL+" ON "+FTS_VIRTUAL_TABLE_CELL+"."+DataCellQuery.KEY_CID+"="+FTS_VIRTUAL_TABLE_PROFILE+"."+DataProfileQuery.KEY_CELL_ID);
      builder.setProjectionMap(mColumnMap_CombinedTable);
      Cursor cursor = builder.query(mDatabaseOpenHelper.getWritableDatabase(), columns, selection, selectionArgs, null, null, null);
      if (cursor == null) return null;
      else if (!cursor.moveToFirst()) {
          cursor.close();
          return null;
      }   
      return cursor;
  </code></pre>
  
  <p>and here is my HashMap being used:</p>
  
  <pre><code>private static HashMap&lt;String, String&gt; buildColumnMap_CombinedTable() {
          HashMap&lt;String,String&gt; map = new HashMap&lt;String,String&gt;();
        for (String key: DataCellQuery.KEYS) map.put(key, key);
        map.put(BaseColumns._ID, "rowid AS " + FTS_VIRTUAL_TABLE_CELL+ "."+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);
        return map;
          }
  </code></pre>
  
  <p>The query is perfect if I do not get the _id from the Cell table, but I need that in my code. How can I get rid of that??? The following error message is what I get...</p>
  
  <pre><code> 05-19 15:56:05.054: ERROR/AndroidRuntime(7772): Caused by: android.database.sqlite.SQLiteException: near ".": syntax error: , while compiling: SELECT rowid AS FTSCell._id, KEY_MCC, KEY_MNC, KEY_CID, KEY_LAC FROM FTSProfile LEFT JOIN FTSCell ON FTSCell.KEY_CID=FTSProfile.CELL_ID WHERE (NAME="PX9RKTPYW4")
  </code></pre>