Menu

SQL AND, OR and NOT Operator Examples


In the previous chapter we have learn how to filter record using where clause using one condition.

In this chapter we are going to learn how to filter record using where clause using more than one condition.

And or not operator used in where clause to write more than one condition.

And

And is a logical operator used to combines more than one conditions and returns TRUE if all condition is TRUE otherwise it return FALSE .

Syntax

SELECT column1_name, column2_name,...
FROM table_name
WHERE condition1 AND condition2...;

OR

Similarly OR is a logical operator used to combines more than one conditions .But it returns TRUE if one of the condition is TRUE otherwise it return FALSE .

Syntax

SELECT column1_name, column2_name, ...
FROM table_name
WHERE condition1 OR condition2...;

NOT

The NOT operator used to fetch record if the condition is not satisfy.

Syntax

SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;







Connection failed: SQLSTATE[28000] [1045] Access denied for user 'studentdb'@'localhost' (using password: YES)

Subscribe