0

I have following query, that's not working.

select * from table where id in (
   1,2, (select id from another_table)
)

How i can rewrite it?

4 Answers 4

2

How about

select * from table 
where id in (1,2)
   or id in (select id from another_table)

Take care and use parentheses when adding additional WHERE-conditions using and!!!

Sign up to request clarification or add additional context in comments.

Comments

1
select * 
from table 
where id in (1,2) OR id in(
   select id from another_table
)

Comments

0
select * from table where id in (
select 1 as id from dual
union all
select 2 as id from dual
union all
select id from another_table
)

Comments

0
select * from table where id in (
   select 1 from dual
     union all
   select 2 from dual
     union all
   select id from another_table);

I'm using union because this is faster than using an OR clause which also can be used.

Comments

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.