Reputation: 11
I am joining two tables, case and user. My problem is that I want to sensor the user's name and location if he/she is working at location B-D.
I want this
To look like this
This is my code so far, but the name is not censored:
SELECT
c.CaseID,
c.Category,
u.User,
CASE
WHEN u.Location != "A" THEN null
ELSE u.Location
END as Location
FROM cases c
JOIN c.userID on u.userID
Upvotes: 0
Views: 276
Reputation: 69524
Use the same case statement for user column too.
SELECT
c.CaseID,
c.Category,
CASE
WHEN u.Location != "A" THEN null
ELSE u.User
END as User,
CASE
WHEN u.Location != "A" THEN null
ELSE u.Location
END as Location
FROM cases c...... <Your remaining query>
Upvotes: 5