title: Why is this SQL query returning the author name for an article as NULL, if the author has written more than one article?
body: <p>Here are my creation statements:</p>
  
  <pre><code>            String createFeedTable = "CREATE TABLE  rss_feed ("
                  + "channel_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), "
                  + "channelTitle VARCHAR(255), "
                  + "channelLink VARCHAR(255), "
                  + "channelDescription VARCHAR(255), "
                  + "channelPubDate TIMESTAMP, "
                  + "channelLastBuildDate TIMESTAMP,"
                  + "channelIcon BLOB(1M),"
                  + "PRIMARY KEY (channel_ID))";
  
          String createFeedItemTable = "CREATE TABLE  feed_item ("
                  + "  item_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),"
                  + "  itemTitle VARCHAR(255),"
                  + "  itemLink VARCHAR(255),"
                  + "  itemDescription VARCHAR(255),"
                  + "  itemGuid VARCHAR(255),"
                  + "  itemPubDate TIMESTAMP,"
                  + "  channel_ID INTEGER REFERENCES rss_feed(channel_ID),"
                  + "  haveRead BOOLEAN DEFAULT FALSE,"
                  + "  PRIMARY KEY (item_ID))";
  
          String createCategoryTable = "CREATE TABLE  category ("
                  + "category_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),"
                  + "categoryName VARCHAR(255), "
                  + "CONSTRAINT category_constraint UNIQUE (categoryName),"
                  + "PRIMARY KEY (category_ID))";
  
          String createFeedItemCategoryTable = "CREATE TABLE  feed_item_category ("
                  + "  item_ID INTEGER REFERENCES feed_item(item_ID),"
                  + "  category_ID INTEGER REFERENCES category(category_ID))";
  
          String createFeedCategoryTable = "CREATE TABLE  rss_feed_category ("
                  + "feed_ID INTEGER REFERENCES rss_feed(channel_ID),"
                  + "category_ID INTEGER REFERENCES category(category_ID))";
  
          String createAuthorTable = "CREATE TABLE  author ("
                  + "author_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),"
                  + "authorName VARCHAR(255),"
                  + "CONSTRAINT author_constraint UNIQUE (authorName),"
                  + "PRIMARY KEY (author_ID))";
  
          String createFeedItemAuthorTable = "CREATE TABLE  feed_item_author ("
                  + "item_ID INTEGER REFERENCES feed_item(item_ID),"
                  + "author_ID INTEGER REFERENCES author(author_ID))";
  </code></pre>
  
  <p>My query:</p>
  
  <pre><code>SELECT i.ITEMTITLE, i.ITEMLINK, i.ITEMDESCRIPTION, i.ITEMPUBDATE, i.CHANNEL_ID,
    i.ITEM_ID, a.AUTHOR_ID, a.AUTHORNAME
  
      FROM FEED_ITEM i
      LEFT JOIN FEED_ITEM_AUTHOR fia
           ON i.ITEM_ID = fia.ITEM_ID
      LEFT JOIN AUTHOR a
           ON fia.ITEM_ID = a.AUTHOR_ID;
  </code></pre>
  
  <p>The Result:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table border =1&gt;
  &lt;tr&gt;  
  &lt;th&gt;ITEMTITLE&lt;/th&gt;
  &lt;th&gt;ITEM_ID&lt;/th&gt;
  &lt;th&gt;AUTHOR_ID&lt;/th&gt;
  &lt;th&gt;AUTHORNAME&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center"&gt;Lawyers...&lt;/td&gt;
  &lt;td align="center"&gt;1&lt;/td&gt;
  &lt;td align="center"&gt;1&lt;/td&gt;
  &lt;td align="center"&gt;Joe Mullin&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center"&gt;AT&amp;T/Time Warner...&lt;/td&gt;
  &lt;td align="center"&gt;2&lt;/td&gt;
  &lt;td align="center"&gt;2&lt;/td&gt;
  &lt;td align="center"&gt;Jon Brodkin&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="center"&gt;The “technosphere” ...&lt;/td&gt;
  &lt;td align="center"&gt;19&lt;/td&gt;
  &lt;td align="center"&gt;19&lt;/td&gt;
  &lt;td align="center"&gt;Annalee Newitz&lt;/td&gt;
  &lt;/tr&gt;
    &lt;tr&gt;
  &lt;td align="center"&gt;Decrypted: ...&lt;/td&gt;
  &lt;td align="center"&gt;20&lt;/td&gt;
  &lt;td align="center"&gt;&amp;lt;null&amp;gt;&lt;/td&gt;
  &lt;td align="center"&gt;&amp;lt;null&amp;gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The table, <strong>feed_item_author</strong>, has the correct number of authors and items - 15 authors and 20 items and matches the data properly line for line.</p>
  
  <p>The tables, <strong>author</strong> and <strong>feed_items</strong> also have the correct number of rows - 15 authors, and 20 feed_items.</p>
  
  <p>I also have in my code to verify that everything has been entered correctly:</p>
  
  <pre><code>  try {
  
          feedItem_AuthorStatement = conn.prepareStatement(feed_item_author_SQL, PreparedStatement.RETURN_GENERATED_KEYS);
  
          feedItem_AuthorStatement.setInt(1, item_ID);
          feedItem_AuthorStatement.setInt(2, author_ID);
          int entrySuccess = feedItem_AuthorStatement.executeUpdate();
  
          System.out.println("SUCCESS? :" + entrySuccess);
      } catch (SQLException ex) {
          Logger.getLogger(FeedItemCategoryHelper.class.getName()).log(Level.SEVERE, null, ex);
      }
  </code></pre>
  
  <p>What am I missing here? Why does my query return null for the author's name and id, if the author has written more than one article?</p>