Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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?
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!!!
WHERE
and
Add a comment
select * from table where id in (1,2) OR id in( select id from another_table )
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 )
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.
Required, but never shown
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.
Explore related questions
See similar questions with these tags.