Multiple value in a string referring thru a variable.

Database

Multiple value in a string referring thru a variable.

Hi All,

I am facing one issue like below:

Table1-> column1 is having value like: 'abc','def','ghi'

i want to fetch all the records from Table2 having the same values in Column2 of this table.

Please do give your suggestions.

Thanks,

Vivek

ex:

sel * from tab2 where col2 in ( select col1 from table1 where <condition>);

output: No Records found.

sel * from tab2 where col2 in (  'abc','def','ghi');

output: 3 records found.

select col1 from table1 where <condition> ;

output:  'abc','def','ghi'

1 REPLY
Senior Apprentice

Re: Multiple value in a string referring thru a variable.

What's your TD release?

In TD14 you might utilize STRTOK_SPLIT_TO_TABLE like:

WITH cte (col1) as
(
select col1 from table1 where <condition>
)
sel * from tab2 where col2 in
(
SELECT token
FROM TABLE (STRTOK_SPLIT_TO_TABLE(1,
cte.col1, ',')
RETURNS (outkey INTEGER,
tokennum INTEGER,
token VARCHAR(20) CHARACTER SET UNICODE)
) AS d
)