title: MySQL force replace to work with collation
body: <p>I have a query in SQL that looks more or less like this:</p>
  
  <pre><code>select replace('Hello World', 'World', '') -- Returns  Hello 
  </code></pre>
  
  <p>Now I want to use same function with utf-8 characters like this:</p>
  
  <pre><code> select replace('Hello Wórld', 'World', '') -- Should Return Hello, but returns Hello Wórld
  </code></pre>
  
  <p>Note that I already have the collation set to utf-8 case insesitive; </p>
  
  <p>following query returns true: </p>
  
  <pre><code>select 'ó' = 'o' -- Returns 1
  </code></pre>
  
  <p>Is there a quick way to make REPLACE function work as I expect?</p>
  
  <p>Thank you.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I´m posting the real piece of code where I build the query, I didn´t think that it could help, but anyway, here it is:</p>
  
  <pre><code>...
  self::$sql.="
          0";
          foreach ( $fields as $field=&gt;$weight) { 
  
              foreach ( $keywords as $keyword ) { 
                  self::$sql.="
                  +COALESCE((LENGTH($table.$field) - LENGTH(REPLACE(LOWER($table.$field), LOWER('$keyword'), '')) )
                  *$weight/LENGTH('$keyword'), 0)
                  *COALESCE((LENGTH($table.$field) - LOCATE('$keyword', $table.$field))/LENGTH($table.$field), 0)
              ";
          }
      }
      self::$sql.=" AS weight";
  </code></pre>
  
  <p>...</p>