title: MYSQL: sorting by 2 columns that have similar data
body: <p>I have 2 columns, called GenreID, and CustomGenre (referring to the genre of a book). GenreID is an integer which refers to genres listed in a different table, in a colume called GenreName. CustomGenre allows the user to enter their own text for this row if they don't like any of the pre-defined options, or if they want to add more information, like a subgenre.</p>
  
  <p>What I'd like to be able to do, is sort these alphabetically simultaneously, with the preference for GenreName. So, if the row has a GenreID, then it gets sorted by GenreName. If the row doesn't have a GenreID (or it's zero) then CustomGenre gets treated as if it were GenreName, so that I end up with a list where if I display "GenreName, CustomGenre" it's actually in alphabetical order, even if the row did not refer to any GenreName.</p>
  
  <p>Just in case that's not clear, here's a little example:</p>
  
  <pre>
  Genre:
  GenreID  GenreName
  1        Sci-Fi
  2        Fantasy
  </pre>
  
  <pre>
  Books:
  Book           GenreID   CustomGenre
  Example        1          Futurism
  A Book         2 
  Another Book!             Horror
  </pre>
  
  <p>And I'd like those to get sorted like this, where the 2nd column is alphebetized:</p>
  
  <pre>
  Results:
  Book            GenreName + CustomGenre
  A Book            Fantasy
  Another Book!     Horror
  Example           Sci-fi, Futurism
  </pre>
  
  <p>Thanks!</p>