Posted By

ginoplusio on 10/20/12


Tagged

mysql select insert update tips


Versions (?)

Remap values inside a MYSQL query using CASE...WHEN syntax


 / Published in: MySQL
 

URL: http://www.barattalo.it/2012/10/19/13-mysql-tips/

How to remap a value to another inside a mysql query select.

  1. SELECT id,title,
  2. (CASE DATE WHEN '0000-00-00' THEN '' ELSE DATE END) AS DATE
  3. FROM your_table
  4.  
  5. SELECT id,title,
  6. (CASE status WHEN 0 THEN 'open' WHEN 1 THEN 'close' ELSE 'standby' END) AS status
  7. FROM your_table

Report this snippet  

You need to login to post a comment.