HELP: WHERE Clause based on value of the column
568915Apr 28 2007 — edited Apr 29 2007I am selecting from a table as follows and want to have a where condition that is dependent of the value of the column, type of the current row.
CREATE TABLE tbl (INT id, VARCHAR type, VARCHAR comment)
I have 3 different values for the type column, EMPLOYEE, CUSTOMER, SUPPLIER. What I want is to have a where clause in my select that is based on the value of type.
I tried the following but was not successful..
SELECT * from tbl
CASE
WHEN type = 'EMPLOYEE' THEN
WHERE comment LIKE '%employee%'
WHEN type = 'CUSTOMER' THEN
WHERE comment LIKE '%customer%'
WHEN type = 'SUPPLIER' THEN
WHERE comment LIKE '%supplier%'
END
I am not proficient with stored procedures so if you could please tell me how to do it with straight query, I would greatly appreciated it..
Thank you,