title: How to compare trimmed variable in SQL statement?
body: <p>I have a SQL statement which includes three database tables. I am comparing some IDs and DESCRIPTIONs and now I need to compare results FIRSTNAME, MIDDLENAME and SURNAME. </p>
  
  <pre><code>SELECT UGOVARATELJ_OSIGURANJA AS ULJEZ FROM INS_RAZNO.TEST_DOWNJONES 
  WHERE UGOVARATELJ_OSIGURANJA IN 
  (SELECT  FIRSTNAME||' '||MIDDLENAME||' '||SURNAME 
  AS IME_PREZIME 
  FROM (SELECT FIRSTNAME, MIDDLENAME, SURNAME 
  FROM INS_RAZNO.AML_CTF
  WHERE ID IN (SELECT ID FROM INS_RAZNO.AML_CTF_DESCRIPTIONS 
  WHERE DESCRIPTION1='1' OR DESCRIPTION1='2')));
  </code></pre>
  
  <p>Variable <code>UGOVARATELJ_OSIGURANJA</code> is actually name of the client in form NAME MIDDNAME SURNAME, with spaces between each part of the name.
  My idea was to remove those spaces with <code>REMOVE()</code> but when I compare after that with second table there is no correct result.</p>
  
  <p>I tried to test my statement with this: THIS IS ONLY TEST STATEMENT</p>
  
  <pre><code>SELECT REPLACE(UGOVARATELJ_OSIGURANJA, ' ','') AS ULJEZ FROM 
  INS_RAZNO.TEST_DOWNJONES WHERE UGOVARATELJ_OSIGURANJA LIKE '%IVAN F%'
  </code></pre>
  
  <p>Notice that I had to set space between name and middname <code>LIKE %IVAN F%</code> and correct way would be %IVANF%.</p>
  
  <p>Any idea how to solve this? Thanks in advance</p>
  
  <p>EDIT: I am doing this replacing (trimming) because some of the peops on my lists have not MIDDLENAME</p>
  
  <p>EDIT:
  This is working statement for names which has MIDDLENAME. 
  The statement is not working properly when someone has no MIDDLENAME because of one space too much.</p>