advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Using SQL's EXISTS Predicate to Identify Missing Data

Sometimes, knowing that data is missing is just as important as finding data that exists. Use SQL's EXISTS predicate to select data based on the presence (or absence) of other values.  


advertisement
inding data in a relational database is usually a simple task, especially if you're simply comparing entries to a specific value, but queries rapidly become more complicated when you start hunting for data that's missing, in other words, data that could exist, but doesn't. Missing data is data related to existing data that simply doesn't occur. You could find missing values using a two-query solution, but SQL's EXISTS predicate can help you quickly find missing values with just one query—a subquery to be exact.


For example, you may create a query to find active customers by counting recent orders. However, finding inactive customers may be just as important; perhaps you can learn why they're inactive and perhaps turn them into active customers. In this article, you'll see how to use the SQL EXISTS predicate to find missing data. This article is aimed at the Jet and Transact-SQL (T-SQL) audience. We'll offer specific instructions when syntax or rules differ between the two dialects.

It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement