In SQL, there is many way to validate if one information exist in another table (or same).
The most used/viewed call is :

  1. SELECT a FROM tablea WHERE a IN (SELECT b FROM tableb)

The problem with this call the long time of execution in case if our tables contains millions of lines.

Our solution to avoid this problem is to use the exists keyword.

  1. SELECT a FROM tablea WHERE EXISTS (SELECT b FROM tableb WHERE tablea.a = tableb.b)

Exists can help you to get result faster.