title: Help understandaing this mySQL query with ORDER BY and CASE
body: <p>I am trying to understand this mySQL query. It supposedly searches the table 'items' with search keyword 'brown fox lazy dog' and returns the result based on its relevancy or number of times it occurs in the records.</p>
  
  <pre><code>SELECT *
  FROM `items`
  WHERE `description` LIKE 'quick'
  AND (
    `description` LIKE 'brown'
    OR `description` LIKE 'fox'
    OR `description` LIKE 'lazy'
    OR `description` LIKE 'dog'
  )
  ORDER BY (
    (
      CASE WHEN `description` LIKE 'brown'
      THEN 1
      ELSE 0
      END
    ) + (
      CASE WHEN `description` LIKE 'fox'
      THEN 1
      ELSE 0
      END
    ) + (
      CASE WHEN `description` LIKE 'lazy'
      THEN 1
      ELSE 0
      END
    ) + (
      CASE WHEN `description` LIKE 'dog'
      THEN 1
      ELSE 0
      END
    )
  ) DESC
  LIMIT 0, 30
  </code></pre>
  
  <p>The part which I dont understand is in the part in the ORDER BY and  CASE clauses. Say a particular record matches all 4 keywords being searched, we get ORDER BY (4)? How is this 4 linked to the parrticular row being considered? What I understand is that ORDER BY is normally used on a column and not a number? Thanks!  </p>