Selecting with more than 1 condition.

suggest change

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

Name | Age | Gender |
—— | —— | —— |
Sam | 18 | M |
John | 21 | M |
Bob | 22 | M |
Mary | 23 | F |

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 |

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents