title: Mysql Syntax "if length then" statement
body: <p>I have a problem with syntax from mysql.
  i have my subselect:</p>
  
  <pre><code>(SELECT uniqueid AS uniqueid_idx, calldate, src, dst, dstchannel, billsec, 
   SUBSTR(CONVERT(IF(LENGTH(dst)&gt;8,cdr.dst,CONCAT('67',cdr.dst)),UNSIGNED INTEGER),1,6) prefixo_normal 
  FROM cdr)
  </code></pre>
  
  <p>Can you see: "if you have cdr.dst > 8 then concat.."
  now i want verify: "if cdr.dst have  &lt;5 then create virtual column name RAMAL"</p>
  
  <p>I have tried this syntax: <code>IF(LENGTH(cdr.dst)  &lt;4, THEN cdr.dst AS ramal END</code></p>
  
  <p>but not working.</p>
  
  <p>How can i do it?</p>
  
  <p>Thank you !</p>