title: How to return rows when you have foreign keys to two different tables
body: <p>I have three tables - feed, posts, polls.</p>
  <p>feed -</p>
  <pre><code> id not null auto_increment,
   post_id int NULL,
   CONSTRAINT FOREIGN KEY post_id REFERENCES posts(id),
   poll_id int NULL,
   CONSTRAINT FOREIGN KEY poll_id REFERENCES polls(id)
  </code></pre>
  <p>posts -</p>
  <pre><code>id int not null auto_increment,
  body varchar(200) not null
  </code></pre>
  <p>polls -</p>
  <pre><code>id int not null auto_increment,
  question varchar(40) not null
  </code></pre>
  <p>Depending on whether the entry is a post or a poll one of the foreign key columns will be null. What I want to do is fetch both posts and polls from the feed table in descending order by the feed.id.</p>
  <p>So far I tried the following query:</p>
  
  <pre><code>SELECT
      posts.body as post_body,
      posts.user_id as post_writer,
      polls.question as poll,
      polls.user_id as poll_writer
  FROM feed
  JOIN posts ON feed.post_id = posts.id
  JOIN polls ON feed.poll_id = polls.id
  ORDER BY feed.id DESC;
  </code></pre>
  <p>But it returns 0 rows. I would appreciate every help. Thank you I advance</p>