Multiple conditions can be applied in a WHERE clause
You can use AND, OR to combine conditions together.
The AND operator displays a record if all the conditions separated by AND are TRUE.
SELECT * FROM products WHERE price > 50 AND category_id = 1;
This SQL statement selects all fields from the "products" table where the "price" is greater than 50 and the "category_id" is 1.
The OR operator displays a record if any of the conditions separated by OR is TRUE.
SELECT * FROM products WHERE category_id = 1 OR category_id = 2;
This SQL statement selects all fields from the "products" table where the "category_id" is either 1 or 2.
The NOT operator displays a record if the condition(s) is NOT TRUE. It is used to exclude records that meet certain criteria.
SELECT * FROM products WHERE NOT category_id = 1;
This SQL statement selects all fields from the "products" table where the "category_id" is not 1.
SELECT * FROM products WHERE (price > 50 AND category_id = 1) OR (price < 20 AND category_id = 2);