What are the nuances of using sql not in and not exists
This article will explain in detail what are the nuances in the use of sql not in and not exists. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The above two simple Sql, we understand from the surface, the final result of the query should be the same, but the actual result is not the same as we expected.
The result of the first sql query has a piece of data
The result of the second sql query is empty
Reason:
For the subquery of not exists, there is a difference between the query results that the subquery does not return rows and the subquery that returns rows.
These small differences must not be ignored by us, and once the project is large, the time it takes to track down specific errors is considerable. Try to stifle these unnecessary mistakes in the cradle.
The above two simple Sql, we understand from the surface, the final result of the query should be the same, but the actual result is not the same as we expected.
The result of the first sql query has a piece of data
The result of the second sql query is empty
Reason:
For the subquery of not exists, there is a difference between the query results that the subquery does not return rows and the subquery that returns rows.
These small differences must not be ignored by us, and once the project is large, the time it takes to track down specific errors is considerable. Try to stifle these unnecessary mistakes in the cradle.
So much for sharing about the nuances in the use of sql not in and not exists. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.