0

In a varchar2 field (table1.field1), I have something like this: ;number1;number2;.......;numberN;

I want use this value in a IN statement, something like:

SELECT * FROM table2 WHERE table2.field2 IN table1.field1
3
  • Question is not clear.. what do you want to do with number1, number2.. and what is table1.field1 Commented Jul 13, 2012 at 14:38
  • You'll have to apply regex to get numbers from this string. Commented Jul 13, 2012 at 14:38
  • In Field1 of Table1 is stored a varchar2 string like this: ";number1;number2;.....;numberN;" where number1,number2,....numberN are numbers. I want to make a select from Table2 filtered by the number in Table1.Field1. Something like: SELECT * FROM TABLE2 WHERE TABLE2.FIELD2 IN (numbers in my TABLE1.FIELD1) Commented Jul 13, 2012 at 16:00

1 Answer 1

1

If the values of table2.field2 are strings like number1
number2

Then Try this:

SELECT * 
    FROM table2 
 WHERE EXISTS
    (
        SELECT 1
          FROM table1
         WHERE table1.field1 LIKE '%;' || table2.field2 || ';%'
    )  

If the table2 are similar to what you have in table1.field1 then try this:

SELECT * 
    FROM table2 
 WHERE field2 IN 
    (
        SELECT field1
          FROM table1
    )  
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Chandu, the first solution is what I need!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.