Difference between EXISTS and IN in SQL?

前端 未结 21 1794
执笔经年
执笔经年 2020-11-22 16:50

What is the difference between the EXISTS and IN clause in SQL?

When should we use EXISTS, and when should we use IN

21条回答
  •  醉话见心
    2020-11-22 17:31

    My understand is both should be the same as long as we are not dealing with NULL values.

    The same reason why the query does not return the value for = NULL vs is NULL. http://sqlinthewild.co.za/index.php/2010/02/18/not-exists-vs-not-in/

    As for as boolean vs comparator argument goes, to generate a boolean both values needs to be compared and that is how any if condition works.So i fail to understand how IN and EXISTS behave differently .

提交回复
热议问题