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!

How to compare a string with comma separated values with another comma separated string?

Hi Team,

I have the data like this.

create table employees (ename varchar2(1000), deptno number);

insert into employees values('john,smith',10);

insert into employees values('alex',10);

insert into employees values('king,smith,alex',10);

insert into employees values('mike,steve',20);

select * from employees;

here I'm passing comma separate values to the column 'ENAME' like 'smith,chris'.

select * from employees where ENAME in (:P_ENAME); -- ('smith,chris')

My requirement is that if any of the names we are passing match it should return that string.

eg: If I pass the string 'mike,alex' to P_ENAME then it should return below records

king,smith,alex
alex
mike,steve.

Can you suggest a solution for this?

Thank you.

Comments
Post Details
Added on Jul 24 2023
4 comments
2,218 views