SQL — And Or Not
AND operator
SELECT * FROM users WHERE age > 25 AND city = 'NYC';
OR operator
SELECT * FROM users WHERE age > 25 OR city = 'NYC';
Combined AND/OR
SELECT * FROM users
WHERE (age > 25 OR city = 'NYC')
AND status = 'active';
NOT operator
SELECT * FROM users WHERE NOT city = 'NYC';
SELECT * FROM users WHERE age NOT BETWEEN 20 AND 30;
Truth table
| A | B | AND | OR |
|---|---|---|---|
| T | T | T | T |
| T | F | F | T |
| F | T | F | T |
| F | F | F | F |
Mini Practice
- Use AND operator
- Use OR operator
- Combine AND/OR
- Use NOT operator
Up Next
Continue with Insert - Inserting data.
Related Topics
Frequently Asked Questions about And Or Not
What is And Or Not in SQL?
And Or Not is a fundamental concept in SQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn And Or Not?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn And Or Not.
Why is And Or Not important in SQL?
And Or Not is essential for SQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.