WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

SQL AND & OR Operators


The AND & OR administrators conditions might be consolidated to test numerous conditions in an inquiry. These two administrators are called conjunctive operators.


The SQL AND & OR Operators

The AND administrator shows a record True if both articulation are true.

The OR administrator shows a record True if either articulation are true.


Example Database

In this instructional exercise we will utilize the example database.

Below is a choice from the "Clients" table:

CustomerID FirstName City Country
1

Eva Dallas Germany
2 Maria Houston. Mexico
3 Jhon Texas Mexico
4

Rajesh India UK
5 Stephine New york USA

AND Operator Example

The following SQL articulation chooses all clients from the nation "USA" What's more, the city "New york", in the "Clients" table:

Example

SELECT * FROM Customers
WHERE Country='USA'
What's more, City='New york';

OR Operator Example

The following SQL proclamation chooses all clients from the city "Delhi" OR "New york", in the "Clients" table: 

Example

SELECT * FROM Customers
WHERE City='Delhi'
Or then again City='New york';

Combining AND & OR

When joining these conditions, it is critical to utilize brackets, with the goal that the request to assess each condition is known.

The following SQL articulation chooses all clients from the nation "India" Also, the city must be equivalent to "Delhi" OR "New york", in the "Clients" table:

Example

SELECT * FROM Customers
WHERE Country='Germany'
What's more, (City='Delhi' OR City='New york');
You can settle the same number of conditions as you need.