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
478 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
return value in based on value passed 6 48
oracle sqlplus query delimiter 8 51
Migration from sql server to oracle (IF then else condition ) 13 61
Oracle perfomance issue. 4 47
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.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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.

739 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