1.

Explain AND operator using where in SQL.

Answer»

The operator AND means that the expressions on both sides must be true to return TRUE. If either expression is false AND returns FALSE.
Syntax:
SELECT column1, column2, columnN FROM table_name
WHERE condition1 AND condition2 … AND conditionN;

Example 1:
It would fetch ID, Name and Salary fields from the CUSTOMERS table where salary is greater than 2000 AND age is less than 25 years:
SQL> SELECT ID, NAME, SALARY FROM

CUSTOMERS WHERE SALARY > 2000 AND age < 25;

Example 2:
To find out which employees have been with the company for 5 years or less and have taken more than 20 days leave,:
SQL> SELECT empNAME FROM VACATION WHERE YEARS <= 5 AND LEAVETAKEN > 20;



Discussion

No Comment Found