Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HELP: WHERE Clause based on value of the column

568915Apr 28 2007 — edited Apr 29 2007
I 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,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 27 2007
Added on Apr 28 2007
5 comments
668 views