title: Dealing with special characters in mysql
body: <p>I have 2 mysql tables <code>property</code> and <code>building</code>. In <code>property</code> table i have a field called <code>unitnumber</code> the value in this field is like <code>1a</code>, <code>2b</code> etc.. In the <code>building</code> table i have a  field called <code>address</code> which is in <code>PHP's</code> <code>urlencoded</code> format. The value will be something like <code>26+Dovedale+Place%2C+Parnell</code></p>
  
  <p>Now i want to implement a search function so that when user types <code>1a, 26 Dovedale</code> I need to pull up the result from the database.</p>
  
  <p>Implemented So Far:</p>
  
  <pre><code>    $keyword = preg_replace('/[^a-zA-Z0-9-]/', '', $_REQUEST['keyword']);
      $keyword = str_replace(" ", "-", $keyword);
      $a-&gt;rqNotEmpty('keyword', $keyword);
  
      $query = "SELECT * FROM `buildings` b left join properties p on p.buildingId=b.id 
        WHERE concat(p.floor,p.number,b.address) LIKE '%".$keyword."%'
        or concat(p.number,p.floor,b.address)  LIKE '%".$keyword."'";
  </code></pre>
  
  <p>But now the problem is when i prepare the <code>$keyword</code> variable i will get something like <code>1a26Dovedale</code> and in database after <code>CONCAT</code> the value will be somethign like <code>1a26+Dovedale+Place%2C+Parnell</code>. I cant urlencode the $keyword because the database is not in standardized form. The database my have 2 spaces between the address. So is there a way to <code>urldecode</code> mysql string ?? I am dealing with nearly 4 million records here!!</p>