title: Android Sqlite Inner Join
body: <p>I'm trying to get this</p>
  
  <p><a href="https://i.stack.imgur.com/sCyk8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sCyk8.png" alt="enter image description here"></a></p>
  
  <p>I have 2 tables - Words Table (ID, NAME, TRANSLATION) and WordSynonym Table(synonym_id1, synonym_id2).</p>
  
  <p>All my words are going into first table, and when I need I am creating connection between words via second table. </p>
  
  <p>Now I need to make method to get all synonyms by specific id.</p>
  
  <p>For that I have tried this.</p>
  
  <pre><code>@Override
  public ArrayList&lt;Word&gt; getAllSynonymsByWord(int id) {
      ArrayList&lt;Word&gt; synonyms = new ArrayList&lt;&gt;();
      Cursor c = database.rawQuery("select id, word, translation from " + WordsTable.TABLE_NAME + " inner join " + WordSynonymTable.TABLE_NAME + " on " + WordSynonymTable.COLUMN_WORD_ID + " = " + id, null);
      c.moveToFirst();
      while (!c.isAfterLast()) {
          Word s = new Word();
          s.setId(c.getInt(0));
          s.setName(c.getString(1));
          s.setTranslation(c.getString(2));
          synonyms.add(s);
          c.moveToNext();
      }
      c.close();
      return synonyms;
  }
  </code></pre>
  
  <p>Parameter ID is id of the word I need (id = 1 in picture)
  I want to return words with id = 2 and id = 3 for example 
  but this is not working properly. </p>
  
  <p>What should I change?
  If you need another part of code comment and I will add.</p>