I know how to separate comma-separated column values into different columns. However, my question is how to query these columns in a where condition. I have a sample table named 'Details' below.
User Department
---- ----------
User1 Admin, Accounts
User2 Admin
User3 Admin, Finance
Suppose I want to query the user who is in an Admin
but not in Finance
. As you can see, User1 and User2 satisfy the condition, but User3 doesn't.
How can I build a select query to get the User3 as result
I know the 'like' operator can be used, but not sure how.
SELECT USER
FROM DETAILS
WHERE DEPARTMENT LIKE "Admin"||"Accounts"
AND NOT LIKE "Finance";