title: Ranking results of sql query resultset
body: <p>I want to rank the results of a SQL query resultset according to some conditions:</p>
  
  <ul>
  <li>Occurrences of keyword </li>
  <li>First match keyword to title then company name then another column and so on..</li>
  <li>If keyword matches into more than 2 columns in a particular row then preference/higher rank should be given to that row</li>
  </ul>
  
  <p>FULL TEXT-AGAINST pair can be used for single column but can't satisfy all conditions.
  If there is any way then please share.</p>
  
  <p>Now I'm using this after some suggested answers:</p>
  
  <pre><code>    SELECT * FROM (SELECT *, DATE_FORMAT(date, '%d %b, %Y')AS dt, 
                          case when title LIKE '%".$fkeyword."%' then 6 else 0 end +
                          case when description LIKE '%".$fkeyword."%' then 3 else 0 end +
                          case when Channel_Name LIKE '%".$fkeyword."%' then 1 else 0 end +
                          case when Industry_Name LIKE '%".$fkeyword."%' then 1 else 0 end +
                          case when Company_Name LIKE '%".$fkeyword."%' then 1 else 0 end as score FROM Search
  WHERE title LIKE '%".$fkeyword."%' or
  Channel_Name LIKE '%".$fkeyword."%'  or
  Company_Name LIKE '%".$fkeyword."%'  or
  description LIKE '%".$fkeyword."%' or
  Industry_Name LIKE '%".$fkeyword."%') scored order by score desc
  </code></pre>