Solved

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

Posted on 2012-03-16
5
468 Views
Last Modified: 2012-03-19
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')
0
Comment
Question by:mahjag
5 Comments
 
LVL 73

Expert Comment

by:sdstuber
ID: 37730768
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
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37730775
Is this not a duplicate of your other question?
http://www.experts-exchange.com/Database/Oracle/Q_27635919.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);
0
 
LVL 14

Accepted Solution

by:
leoahmad earned 310 total points
ID: 37732582
and if assumed the two tables have some column relation

select * from tableB
where custid in (select custid from tableA) and cust_zone in (select cust_zone from tableA)
0
 
LVL 32

Expert Comment

by:awking00
ID: 37733225
select b.* from tableA a, tableB b
where b.value = a.cust_id
   or b.value = a.cust_zone;
0
 

Author Comment

by:mahjag
ID: 37733579
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,
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now