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
482 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

696 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