title: mysql SELECT with SUBSTRING, LOWER and REPLACE commands
body: <p>Im trying to do a select on the company name(cpnm) field of our company table but only giving me the first 6 characters, replacing all spaces plus making it lowercase.</p>
  
  <pre><code>SELECT *,
  SUBSTRING(LOWER(cpnm), -LENGTH(cpnm), 6) as test
  FROM company
  LIMIT 100
  </code></pre>
  
  <p>The above works fine but as soon as I try to add the replace spaces (shown below), it doesnt give back results.</p>
  
  <pre><code>SELECT *,
  SUBSTRING(LOWER(REPLACE(cpnm, ' ', '')), -LENGTH(cpnm), 6) as test
  FROM company
  LIMIT 100
  </code></pre>
  
  <p>Any ideas?</p>