Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting data using IN operator

pradeep kateelMar 29 2017 — edited Mar 30 2017

Dear Friends,

I need to get the data from T2 using T1 column data. Basically T1 is holding code and description for the codes are in T2.

In table T1 data is stored as below:

pastedImage_18.png

Description for above code is in table T2 data stored as below:

pastedImage_12.png

Now I have written a code to retrieve the description using T1 table data:

select upper('('''||replace(data1,',',''',''')||''')') from t1;

Result:

('2BA','2R','BAL','HI')

Using IN operator: When I run below code I am not able to get any data.

1. Is there any mistake in my code?

2. Is this the correct way to use the code like below ?

3. Do we have any other idea to get the correct data?

select data1_desc from t2 WHERE upper(data1_desc) IN (

select upper('('''||replace(data1,',',''',''')||''')') from t1);

Result : NULL

Codes to create the table and data:

create table t1 (data1 varchar2(200));

create table t2 (data1 varchar2(200),data1_desc varchar2(2000));

insert into t1 values ('2BA,2R,BAL,HI');

insert into t2 values ('2BA','2 Basket');

insert into t2 values ('2R','2 Room');

insert into t2 values ('BAL','Ball Room');

insert into t2 values ('HI','High Floor with view');

select * from t1;

select * from t2;

select upper('('''||replace(data1,',',''',''')||''')') from t1;

select data1_desc from t2 WHERE upper(data1) IN (

select ('('''||replace(data1,',',''',''')||''')') from t1);

Regards,

Comments

anishjp

Anybody?

Answer

No...if you need more than that, might be time to look at something like APEX. Or build a rest api to pull the data and use your favorite js library to chart the data.
We're building this feature into SQL Developer Web - stay tuned.

Marked as Answer by anishjp · Apr 23 2021
anishjp

Okay, thank you. I will look at APEX then.

Regards,
Anish

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 27 2017
Added on Mar 29 2017
18 comments
980 views