Avatar of mahjag
mahjag
 asked on

combine 2 column values in oracle so that the combined value can be used in an IN clause

Hi

I want to combine 2 column values in oracle and then use that combined value in the IN clause in the second query - how do I do that

Table A - 2 columns - cust_id, cust_zone - values - cust01, PRE - combined value 'custo01','PRE'

Second query

select * from table B where value in ('cust01','PRE')
Oracle Database

Avatar of undefined
Last Comment
mahjag

8/22/2022 - Mon
Sean Stuber

I'm not sure what you're asking,

I think "maybe" you're trying to do this...


select  * from tableB where value in (select cust_zone from tableA)

If that isn't correct please post sample data and expected results.
 not descriptive words, data that I can test with and replicate results
slightwv (䄆 Netminder)

Is this not a duplicate of your other question?
https://www.experts-exchange.com/questions/27635919/dealing-with-connect-by-queries.html



You cannot without dynamic SQL.

Off the top of my head:

select * from tableB where value in (select cust_id from tableA union select cust_zone from tableA);
ASKER CERTIFIED SOLUTION
Muhammad Ahmad Imran

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
awking00

select b.* from tableA a, tableB b
where b.value = a.cust_id
   or b.value = a.cust_zone;
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
mahjag

ASKER
Hi Slightwv

It is not the same as previous question - I do want to get 2 column value as 1 so that i can use the value in a second query that has IN Clause

Please let me know,