I have two tables users
and userdetail
. I am trying to create a view in which if status of userdetail
column is 1 it should show Active
in view and blocked if status is 0:
CREATE VIEW `new` AS
SELECT
users.id AS id,
userdetail.healthissues AS healthissues,
users.fullName AS fullname,
userdetail.`status`,
CASE status
WHEN userdetail.status ='1' THEN userdetail.`status`= 'Blocked'
WHEN userdetail.status= '0' THEN userdetail.`status` ='Active'
END ,
users.phoneNumber AS number
FROM users
JOIN userdetail ON users.id = userdetail.reference
This code does not give the desired result. Can some please help me out with this?