Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 21st, 2012  |  syntax: None  |  size: 0.62 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. MySQL Formating Strings or Returning Empty string on NULL
  2. select if(tinyint_value,'yes','no')
  3.        
  4. select if(property.price is not null, CONCAT('$',FORMAT(property.price,2)),'')
  5.        
  6. select case column when 1 then 'Yes' else 'No' end as columalias ,
  7.        case when stringcolumn is NULL then '' else stringcolumn end as stringcolumn
  8. from table
  9.        
  10. select case column when 1 then 'Yes' else 'No' end as columalias ,
  11.        IFNULL(stringcolumn,'') as stringcolumn
  12. from table
  13.        
  14. SELECT COALESCE(NULL, 1);
  15. -> 1
  16. SELECT COALESCE(2, 1);
  17. -> 2
  18.        
  19. COALESCE(field,'')
  20.        
  21. CASE WHEN fieldtiny = 1 THEN 'Yes' ELSE 'No' END AS YESNOFIELD