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


/ Published in: MySQL
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.