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.

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath White Field Bangalore
3 Goutham Avenue colony Chennai
4 Bhargav James street Chennai
5 Varun Park Avenue Chennai

 


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:

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad

 

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