And, Or and Not operators in SQL 

And, Or and Not operators in SQL

SQL also called structured query language is the language which helps to access and manipulate any databases. It has the features like insert, update, delete, create, store, set permission, etc on the database or to the tables on the database. Although SQL is an ANSI/ISO standard, there are different versions of the SQL language. it can also be used for making the database on the website.
The SQL have many types of commands for specific uses and different clauses. One of the regular used command is the “where” clause. The “where” clause helps to is used to filter records and also used to extract only those records that fulfill a specified condition. The where clause can be used with other syntax, some of them are ‘And’, ‘Or’ and ‘Not’ operators.
 

And operator

The ‘and’ operator is mainly used with the where clause which helps to displays a record if all the conditions separated by AND is TRUE. It helps to show two or more value which are true.
Syntax
SELECT column1, column2, …
FROM table_name
WHERE condition1 AND condition2 AND condition3 …;
 

OR operators

The ‘or’ operators are also used with the where clause which helps to displays a record if any of the conditions separated by OR is TRUE. It shows if one of the given is statement is true.
Syntax
SELECT column1, column2, …
FROM table_name
WHERE condition1 OR condition2 OR condition3 …;
 

Not operators

The ‘not’ operators are also found with the where clause which helps to displays a record if the condition(s) is NOT TRUE.
Syntax
SELECT column1, column2, …
FROM table_name
WHERE NOT condition;
 

Examples

And operators

Syntax
SELECT * FROM Customers
WHERE Country=’Germany’ AND City=’Berlin’;

Or operators

Stntax
SELECT * FROM Customers
WHERE City=’Berlin’ OR City=’München’;

Not operators

Syntax
SELECT * FROM Customers
WHERE NOT Country=’Germany’;

 
 
Credit:  w3schools.com

Leave a Reply

Your email address will not be published. Required fields are marked *