Saturday, September 6, 2014

USE SINGLE QUERY FOR UPDATE STATUS OF ANY ENUM

Create table feedback (
fid int(3),name varchar2(30),
email varchar(20),subject varchar(30),
satatus enum('0','1')); 

UPDATE feedback SET status =  
CASE
  WHEN  1 THEN 0
  WHEN 0 THEN 1
END
WHERE fid = 3;
 
 

SELECT CASE is_status
      WHEN
1 THEN 'Replied'
      WHEN
0 THEN 'Not Replied'
      
END AS 'fstatus'
FROM feedback
;

No comments: