</>
Skip to content
SQL lessons (7/54)

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

ABANDOR
TTTT
TFFT
FTFT
FFFF

Mini Practice

  1. Use AND operator
  2. Use OR operator
  3. Combine AND/OR
  4. 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.