# `IN` and `EXISTS`
__*IN*__
__*EXISTS*__
+ Difference between IN and EXISTS  
```
tidb> SELECT * FROM test.t1;
+------+
| id   |
+------+
| NULL |
+------+
1 row in set (0.00 sec)

tidb> SELECT * FROM test.t1 WHERE id ~!@IN@!~ (SELECT id FROM test.t1);
Empty set (0.00 sec)

tidb> SELECT * FROM test.t1 WHERE ~!@EXISTS@!~ (SELECT id FROM test.t1);
+------+
| id   |
+------+
| NULL |
+------+
1 row in set (0.01 sec)
```

------------------------------------------------------------
IN is interested in the value of the data and EXISTS is interested in the existence of the record rather than the specific numeric value. In the second query, since there exists a result, the value will be returned.


The Exists keyword evaluates true or false, but the IN keyword will compare all values in the corresponding subquery column.  If you are using the IN operator, the SQL engine will scan all records fetched from the inner query. On the other hand, if we are using EXISTS, the SQL engine will stop the scanning process as soon as it found a match.