decision

SQL AND, OR, NOT Operators

SQL AND, OR, NOT Operators

SQL provides logical operators like AND, OR, and NOT to combine conditions in a query.

AND Operator

SELECT first_name, last_name FROM Users
WHERE age > 18 AND gender = 'Female';
    

This query retrieves the names of female users older than 18.

OR Operator

SELECT first_name, last_name FROM Users
WHERE age > 18 OR gender = 'Male';
    

This query retrieves the names of users who are either older than 18 or male.

NOT Operator

SELECT first_name, last_name FROM Users
WHERE NOT gender = 'Male';
    

This query retrieves the names of users who are not male.