title: What is the query for retrieving a list of linked objects in a sqlite database with multiple tables?
body: <p>I have made a sqlite database with the following tables:</p>
  
  <pre><code>public void onCreate(SQLiteDatabase db) {
      db.execSQL("CREATE TABLE "+TABLE_CITY+"("
              +KEY_ID+" INTEGER PRIMARY KEY, "
              +KEY_CITY+" TEXT, "+KEY_COUNTRY+" TEXT)");
      db.execSQL("CREATE TABLE "+TABLE_DIARY+"("
              +KEY_ID+" INTEGER PRIMARY KEY, "
              +KEY_DATE+" TEXT, "+KEY_STORY+" TEXT)");
      db.execSQL("CREATE TABLE "+TABLE_CITY_DIARY+"("
              +KEY_ID+" INTEGER PRIMARY KEY, "
              +KEY_CITY_ID+" TEXT, "+KEY_DIARY_ID+" TEXT)");
  }
  </code></pre>
  
  <p>Now I want to retrieve a list of all the diary entries that belong to a certain city (e.g. Barcelona contains 3 diary entries and Rome 5, but I only want a list of the 3 belonging to Barcelona).
  I made a method for this, but I'm not sure what the query should be.</p>
  
  <pre><code>    public List&lt;Diary&gt; getDiariesByCity(String city_name){
      List&lt;Diary&gt;diaries=new ArrayList&lt;Diary&gt;();
      SQLiteDatabase db=this.getReadableDatabase();
      Cursor curs=db.rawQuery("SELECT * FROM "+TABLE_DIARY........,
              new String[]{city_name});
      if(curs.moveToFirst()){
          do{
              Diary diary=new Diary();
              diary.setId(curs.getInt(curs.getColumnIndex(KEY_ID)));
              diary.setDate(curs.getString(curs.getColumnIndex(KEY_DATE)));
              diary.setStory(curs.getString(curs.getColumnIndex(KEY_STORY)));
              diaries.add(diary);
          }while(curs.moveToNext());
      }return diaries;
  }
  </code></pre>