SQL SELECT Selecting with more than 1 condition.

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

The AND keyword is used to add more conditions to the query.

NameAgeGender
Sam18M
John21M
Bob22M
Mary23F
SELECT name FROM persons WHERE gender = 'M' AND age > 20;

This will return:

Name
John
Bob

using OR keyword

SELECT name FROM persons WHERE gender = 'M' OR age < 20;

This will return:

name
Sam
John
Bob

These keywords can be combined to allow for more complex criteria combinations:

SELECT name
FROM persons
WHERE (gender = 'M' AND age < 20)
   OR (gender = 'F' AND age > 20);

This will return:

name
Sam
Mary


Got any SQL Question?