In conclusion, the NOT EXISTS and NOT IN behave differently when there are null values involved. In diesem Beitrag gehe ich der Frage nach wie bekommt man mit SQL die Datensätze einer Tabelle, die nicht mit einem Datensatz einer anderen Tabelle Verknüpft sind. Es gibt effizientere Methoden zum Schreiben der meisten Abfragen, bei denen die EXISTS -Bedingung nicht verwendet wird.
If a subquery returns any rows at all, EXISTS subquery is TRUE, and NOT EXISTS subquery is FALSE. For example: SELECT columnFROM t1. With NOT EXISTS , I try to use SELECT such as NOT EXISTS (SELECT FROM sometable WHERE something) so that the database does not actually need to return columns from disk. Using EXPLAIN to determine whether this makes a difference in your case is probably a good idea. The SQL NOT EXISTS Operator will act quite opposite to EXISTS Operator.
It is used to restrict the number of rows returned by the SELECT Statement. Oracle insert if not exists statement - Stack. The NOT EXISTS in SQL Server will check the Subquery for rows existence, and if there are no rows then it will return TRUE, otherwise FALSE. If at least one row returns, it will evaluate as TRUE. Since the OP explicitly asked about NOT IN and NOT EXISTS , then the answer really is it depends.
Personally, when I am looking at sql statements, my first choice is fast and right.
