SQL AND

SQL AND clause are used to select data when two conditions are met.

The syntax of SQL AND clause is

SELECT columns
FROM table
WHERE condition1 AND condition2;

 

SQL AND is executed only when both the conditions are met.

Example:

Let us take a Student Table.

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai
4BhargavJames streetChennai
5VarunPark AvenueChennai

 


Now we select the data where the Student City is Hyderabad and Address is Bank Street.

The Query is written as:

SELECT * FROM Student
WHERE
City=’Hyderabad’ AND Address=’Bank street’;

 

The output is displayed as:

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad

 

AND Clause can be used with INSERT, UPDATE & DELETE statements.