SQL AND OR & NOT Operators: These are basic SQL commands to use conditions-based data retrieval. In this we will see how to use this is in MySQL or any other SQL data base.
SQL AND OR & NOT Operators
— 1. If you are using multiple AND, OR operator then make sure you specify in braces (), because the AND operator will be executed first and then the OR.
— 2. NOT is used to do the opposite of any OR & AND results. See the 2nd query, we can find that we used NOT before the condition. It will check the condition and then give result opposite of that.
— 3. The alternate way of NOT is to change the operators wise versa. You can see in the 3rd query. [E.g., “AND” to “OR” and “<” to “<“)]. Click here to get more details!
SELECT *
FROM customers
WHERE
birth_date > '1990-01-28' OR
(points >= 1000 AND state = 'VA');

SELECT *
FROM customers
WHERE NOT (birth_date > '1990-01-28' OR points > 1000);

SELECT *
FROM customers
WHERE birth_date <= '1990-01-28' AND points <= 1000;

Watch Video!
Next Post>> #2.5) IN Operator (Single Table)
<< Previous Post #2.3) Where Clause (Single Table)