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
472 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 74

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 77

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
update using pipeline function 3 21
date show only hh:mm 2 27
Oracle Nested table uses ? 2 35
why truncate is faster than delete in oracle ? 4 27
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.

828 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