title: Selecting Multiple Fields Based Upon Initial Field
body: <p>I am working with a table as below which is actually a file index. The query below tells me which file, and which pages belong to which person. </p>
  
  <pre><code>SELECT file_id, person_id, page FROM file_index;
  </code></pre>
  
  <p>My issue is that I need to select each page after the person_id even though they have NULL values. For instance, pages 2, 3, and 4 all belong to person_id 321456, and pages 6, 7, 8, and 9 belong to 546879. It is also possible for a patient who was in the file earlier to appear later in the file, as in page 10 and am unsure how to write the query to accomplish this.</p>
  
  <pre><code>+---------+-----------+------+
  | file_id | person_id | page |
  +---------+-----------+------+
  | 478779  | 321456    | 2    |
  | 478779  | NULL      | 3    |
  | 478779  | NULL      | 4    |
  | 478779  | 987456    | 5    |
  | 478779  | 546879    | 6    |
  | 478779  | NULL      | 7    |
  | 478779  | NULL      | 8    |
  | 478779  | NULL      | 9    |
  | 478779  | 321456    | 10   |
  +---------+-----------+------+
  </code></pre>