This is beset illustrate by an example that I think should work but doesn't:
select * from TABLE_A where KEY in (
select substr(DYNAMIC_KEY,3) from TABLE_B where DYNAMIC_KEY like '$$%' and RECORD_ID='104251893783388824');
Basically, the inner select statement return a set of result which had a '$$' prefix. This is use as a lookup key in TABLE_A which does not contain the '$$' prefix in the key.
If I manually run the inner statement:
select substr(DYNAMIC_KEY,3) from TABLE_B where DYNAMIC_KEY like '$$%' and RECORD_ID='104251893783388824'
Copy the first result, let say '8462928318772288542' and run the outer select statement
select * from TABLE_A where KEY = '8462928318772288542'
This works.
However, if I ran is as a select in (select ...) statement, I get no result.
Edit:
The database used here is Oracle 10g.
The DYNAMIC_KEY column in TABLE_B is a VARCHAR2
The KEY column in TABLE_A is CHAR 32