title: Mysql: Order by like?
body: <p>assume that we are performing search using keywords: keyword1, keyword2, keyword3</p>
  
  <p>there are records in database with column "name":</p>
  
  <pre>
  1: John Doe
  2: Samuel Doe
  3: John Smith
  4: Anna Smith
  </pre>
  
  <p>now Query:</p>
  
  <pre><code>SELECT * FROM users WHERE (name LIKE "%John%" OR name LIKE "%Doe%")
  </code></pre>
  
  <p>it will select records: 1,2,3 (in this order)
  but i want to order it by keyword
  in example <code>keyword1=John, keyword2=Doe</code>
  so it should be listed by keywords: 1,3,2 (because i want to perform search for "Doe" after searching for "John")</p>
  
  <p>I was thinking about <code>SELECT DISTINCT FROM (...... UNION .....)</code>
  but it will be much easier to order it somehow in another way (real query is really long)</p>
  
  <p>are there any tricks to create such order?</p>