title: Alternative for Find_in_set which can use index
body: <p>I have a my sql stored procedure where i am passing a list of numbers as a comma separated mediumtext field</p>
  
  <p>For checking if my parameter matched i am using Find_in_set in my stored procedure as follows</p>
  
  <pre><code>SELECT SQL_CALC_FOUND_ROWS f1,f2,f3,f4 FROM `mytable`
  WHERE FIND_IN_SET(f2,'1,2,4,5,6,6,7,8,8,4,9,7.......................') &gt; 0
  ORDER BY f1 DESC        
  LIMIT 25 OFFSET 0
  ;
  
  SELECT FOUND_ROWS();
  </code></pre>
  
  <p>Now problems with Find_in_set i found out later is that it doesn't used index due to which My query is taking too long to complete.
  Please suggest any improvement in the query</p>
  
  <p>P.S.</p>
  
  <p>Following is my complete stored procedure (including the changes as suggested in below answer)</p>
  
  <pre><code>    DECLARE _calculated_offset INT;
      SET _calculated_offset = _limit * (_pageNumber -1);
      IF _calculated_offset &lt; 0 THEN  
          SET _calculated_offset = 0;
      END IF;         
  
      /*SELECT SQL_CALC_FOUND_ROWS f1,f2,f3,f4  FROM `mytable`
      WHERE FIND_IN_SET(f1,_telcoIdList) &gt; 0  
      AND FIND_IN_SET(f2,_msisdnList) &gt; 0 
      ORDER BY f3 DESC        
      LIMIT _limit OFFSET _calculated_offset
      ;
  
      SELECT FOUND_ROWS();*/
  
  
  SET @query = CONCAT('SELECT SQL_CALC_FOUND_ROWS f1,f2,f3,f4
      FROM `mytable`
      WHERE f1 in (',_telcoIdList,')
      AND f2 in (',_msisdnList,') 
      ORDER BY f3 DESC        
      LIMIT ', _limit,' OFFSET ',_calculated_offset,' ;
  
      SELECT FOUND_ROWS();
  
      '); 
      PREPARE stmt FROM @query; 
      EXECUTE stmt; 
      DEALLOCATE PREPARE stmt; 
  </code></pre>