title: SELECT in MariaDB 10.3 which finds all records with and without spaces
body: <p>I have a query for SELECT in MariaDB 10.3, which finds all records with and without spaces (accepting accents at the same time). Spaces can be anywhere (after each character, for example).</p>
  <p>If I have in the database in the column 'code' value: <strong>ŘCT 111 222 33 33</strong></p>
  <ul>
  <li>So I want it to find me the code by entering with spaces <strong>ŘCT 111 222 33 33</strong> and without spaces <strong>ŘCT1112223333</strong>.</li>
  <li>At the same time, I need it to accept diacritics, ie. to find the code by entering both with the diacritics <strong>ŘCT1112223333</strong> and without <strong>RCT1112223333</strong>.</li>
  </ul>
  <p>I call SELECT in PHP, so I do <strong>chunk_split_unicode()</strong> (see below) first and then SELECT with RLIKE, but it does not accept diacritics, if I enter only <strong>RCT1112223333</strong>, then it will not find anything.</p>
  <p>Any easier way?</p>
  <p>I will be happy for any advice. Thank you so much.</p>
  <p>Martin</p>
  <pre><code>$text = &quot;RCT1112223333&quot;;
  $param = chunk_split_unicode($text, 1, ' ?');
  $query = &quot;SELECT * FROM Data WHERE code RLIKE &quot; . $param;
  
  public static function chunk_split_unicode($str, $l = 76, $e = &quot;\r\n&quot;) {
          if (is_null($str)) {
              $str = &quot;&quot;;
          }
          $tmp = array_chunk(preg_split(&quot;//u&quot;, $str, -1, PREG_SPLIT_NO_EMPTY), $l);
          $str = &quot;&quot;;
          foreach ($tmp as $t) {
              $str .= join(&quot;&quot;, $t) . $e;
          }
          // jelikoz se v SQL pouzivaji REGEXP, tak je nutne vyescapovat znaky pouzivane v reg. vyrazech
          $str = str_replace(array('(', ')', '[', ']', '{', '}', '*' , '+'),  array('\(', '\)', '\[', '\]', '\{', '\}', '\*', '\+'), $str);
          return $str;
      }
  </code></pre>
  <p><em>Edit: SQL query</em></p>
  <p>SQL query <code>SHOW CREATE TABLE</code> data is:</p>
  <pre><code>CREATE TABLE `data` (
   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
   `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
   `code` varchar(250) NOT NULL DEFAULT '',
   `name` varchar(250) NOT NULL DEFAULT '',
   `description` varchar(250) NOT NULL,
   PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=4282 DEFAULT CHARSET=utf8
  </code></pre>