AND, OR & NOT are used when the conditions for selecting an entry are more specific. These keywords are used along with WHERE. They are the logical operators. They can also be used with these symbols.
AND (&&)
OR (||)
NOT (!)
Syntax:
1. SELECT column name...[column names]
from Table name
WHERE(condition 1 AND condition 2);
2. SELECT column name...[column names]
from Table name
WHERE(condition 1 OR condition 2);
3. SELECT column name...[column names]
from Table name
WHERE(NOt condition);
Examples
mysql> SELECT * from
-> students
-> where (Section ='B' || Class = 11);

mysql> SELECT * from
-> students
-> where (Section ='B' && Class = 11);

mysql> SELECT * from
-> students
-> where (Class != 11);
OR
mysql> SELECT * from
-> students
-> where (NOT Class = 11);

Leave a comment