title: Auto-suggest of airfields - how to order "best match first" across several columns?
body: <p>Given the following table structure:</p>
  
  <pre><code>id  iata  icao  name
   1  ANC   PANC  Anchorage - Ted Stevens International
   2  LHR   EGLL  London - Heathrow
   3  LGW   EGKK  London - Gatwick
   4  MDZ   SAME  Mendoza - Governor Francisco Gabrielli International
  </code></pre>
  
  <p>what's the best way to extract the records in "best match first" order, as you would expect in an auto-suggest field at a travel agent site? A match on <code>="string"</code> in any one column should take precedence over a match on <code>LIKE "%string%"</code> in any other. After that, alphabetical order on "name" is probably what I want.</p>
  
  <p>For example, searching "anc" would return row 1 then row 4. "lon" would get 3 then 2.</p>
  
  <p>IATA codes are always 3 characters, ICAO always 4. However, either or both may be NULL.</p>
  
  <p>While I would expect my AJAX to submit three characters and filter in Javascript from there, I can't assume that the input will be three characters - non-Javascript users will be submitting a string of arbitrary length.</p>
  
  <p>I'm doing this in PHP with MySQL.</p>