MYSQL AND condition:
Basically, We use AND operator when there is more than one condition and result will depend on both condition to be true.
-AND is used with select,insert,delete command.
Syntax:
WHERE condition1 AND conditions2...
Display all record of table employee:
SELECT * FROM employee;
emp_id |
emp_name |
department |
emp_salary |
1 |
Aman |
D1 |
34000 |
2 |
Ram |
D2 |
43000 |
3 |
Ramesh |
D1 |
20000 |
4 |
John |
D3 |
65000 |
5 |
Sita |
D1 |
10000 |
6 |
Dinesh |
D2 |
15000 |
Now we display the employee detail who belongs to department D1 and have salary equal to 20000.
SELECT * FROM employee WHERE department=D1 AND emp_salary=20000;
emp_id |
emp_name |
department |
emp_salary |
3 |
Ramesh |
D1 |
20000 |
-In this Query we use AND between two conditions. so we get the result when both the condition is True.