Exists and in are doing the same thing. Why do we need to solve two problems? in fact, they are efficiency problems. For example, the following two examples 1. select * fromt1whereexists (selectXfromt2wheret1. at2.a) PS: replace 'x with any other regular bright characters, such as the number character "etc. 2. select * fromt1wheret1. ai
Exists and in are doing the same thing. Why do we need to solve two problems? in fact, they are efficiency problems. For example, the following two examples 1. select * from t1 where exists (select 'x' from t2 where t1.a = t2.a) PS. 2. select * from t1 where t1.a I
Exists and in do the same thing, so why do we need to get two more? It is actually a matter of efficiency.
For example, the following two examples
1. select * from t1 where exists (select 'x' from t2 where t1.a = t2.a)
PS: The 'X' here can be changed to any other regular bright, such as the numeric character etc.
2. select * from t1 where t1.a in (select t2.a from t2)
When exists is used, oracle first executes the primary query and then the subquery. Therefore, when the t1 data volume is small and the t2 data volume is large, the efficiency is high,
When in is used, oracle will first execute the subquery and then the primary query. Therefore, when the t2 data volume is small, the efficiency is high when the t1 data volume is large.