Loading section...

IN and NOT IN for list matching

Concepts: sqlInList

List matching simplifies queries when you need to check against multiple possible values at once. If the column value matches ANY item in the list, the row is kept. Example The "food" row is the only one rejected because it does not appear in the list. Every other type matches at least one entry and passes through to the result. Why IN Is Powerful More Examples Problem: Show sales from three specific categories. Problem: Get data for four specific customer IDs. How does IN handle a longer list of values? Excluding with NOT IN Basic Syntax Basic Example This returns all orders except those that were cancelled, refunded, or failed. The database checks each row's status against the exclusion list and returns rows that don't match any of the values. Real-World Example This filters a sales repo