title: Optimizing MySQL search query
body: <p>Need yours help optimizing one mysql query. Lets take simple table for example. </p>
  
  <pre><code>CREATE TABLE `Modules` (
   `ID` int(11) NOT NULL AUTO_INCREMENT,
   `moduleName` varchar(100) NOT NULL,
   `menuName` varchar(255) NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `moduleName` (`moduleName`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8
  </code></pre>
  
  <p>Lets Fill it with some data:</p>
  
  <pre><code>INSERT INTO  `Modules` (`moduleName` ,`menuName`)
  VALUES 
      ('abc1',  'name1'), 
      ('abc',  'name2'), 
      ('ddf',  'name3'), 
      ('ccc',  'name4'), 
      ('fer',  'name5');
  </code></pre>
  
  <p>And some sample string. Let it be <code>abc_def</code>;</p>
  
  <p>Traditionally we are trying to find all the rows containing search string.</p>
  
  <p>On the contrary, my task is, to find all rows which contains <code>moduleName</code> in input string. For now I have following query to get desired result:</p>
  
  <pre><code>SELECT `moduleName` ,`menuName` 
  FROM `Modules` 
  WHERE 'abc_def' LIKE(CONCAT(`moduleName`,'%'))
  </code></pre>
  
  <p>This will return </p>
  
  <pre><code>moduleName   | menuName 
  ---------------------------
  abc          | name2
  </code></pre>
  
  <p>The problem is, that this query is not using index. </p>
  
  <p>Is there some way to force it to use one? </p>