Getting SQL error for replace function
<p>I'm not to sure why this is happening and i've been trying to figure it out now for a while. </p>

<p>I've got the follow code</p>

<pre><code>SELECT (MAX(replace(replace(replace(`sku`,'PA1-',''),'TES-',''),'BOX-',''))+1) AS maxValue FROM `product` WHERE `sku` LIKE '%PA1-TES-BOX%'
</code></pre>

<p>This was working a while back and nothing has changed code wise, I can only assume that a server changes has caused this to return the following error:</p>

<blockquote>
  <p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near <code>'maxValue FROM ``product`` WHERE ``sku`` LIKE '%PA1-TES-BOX%'</code></p>
</blockquote>

<p>Basically this SQL was built to find the first 3 section of this SKU code and return the ending + 1 so 002 would then return 003 to ensure unique sku codes. </p>

<p>Maybe the replace function has changed, i'm not entirely sure. </p>

<p>Does anyone have any ideas why this suddenly is throwing the error above?</p>