title: SQLite says "no such column: rowid" when using sub-queries
body: <p>Here's a query that works fine:</p>
  
  <pre><code>SELECT rowid as msg_rowid, a, b, c FROM messages m1
  </code></pre>
  
  <p>And here's another one that's also fine:</p>
  
  <pre><code>SELECT rowid as match_rowid FROM messages m2 WHERE x LIKE '%abc%'
  </code></pre>
  
  <p>But if I put them together as follows, SQLite complains:</p>
  
  <pre><code>SELECT rowid as msg_rowid, a, b, c FROM messages m1
  JOIN
      (SELECT rowid as match_rowid FROM messages m2 WHERE x LIKE '%abc%')
  ON
      msg_rowid &gt;= match_rowid - 10 AND msg_rowid &lt;= match_rowid + 5
  </code></pre>
  
  <p>giving what looks like a misleading error message: <code>No such column: rowid</code>.</p>
  
  <p>How can I fix this?</p>
  
  <p>The query runs fine if I use a messages.timestamp field instead of rowid:</p>
  
  <pre><code>SELECT timestamp as msg_ts, a, b, c FROM messages m1
  JOIN
      (SELECT timestamp as match_ts FROM messages m2 WHERE x LIKE '%abc%')
  ON
      msg_ts &gt;= match_ts - 10 AND msg_ts &lt;= match_ts + 5
  </code></pre>
  
  <p>Is this a bug, or a by-design restriction on the use of <code>rowid</code>?</p>