What's the difference between 'not in' and 'not exists'?

前端 未结 4 1851
野的像风
野的像风 2021-02-02 15:08

What\'s the difference between not in and not exists in an Oracle query?

When do I use not in? And not exist?

4条回答
  •  被撕碎了的回忆
    2021-02-02 15:47

    I think it serves the same purpose.

    not in can also take literal values whereas not exists need a query to compare the results with.

    EDIT: not exists could be good to use because it can join with the outer query & can lead to usage of index, if the criteria uses column that is indexed.

    EDIT2: See this question as well.

    EDIT3: Let me take the above things back.
    See this link. I think, it all depends on how the DB translates this & on database/indexes etc.

提交回复
热议问题