Welcome to Our Free Tutorial!

Using AND operator in WHERE clause

Creating Employee Table


The WHERE Clause is used when you want to retrieve specific information from a table.It is use to filter the data.
SQL offers a feature called WHERE clause, which we can use  the WHERE clause filters the rows retrieved from the table and gives you only those rows which you expected to see. WHERE clause can be used along with SELECT, DELETE, UPDATE statements.

     create table Employee(
     ID          int,
     Name        nvarchar (15),
     Salary      int,
     Start_date  datetime,
     State        nvarchar (11),
     Sex      char (2))


Inserting Values into Employee Table

Insert into Employee (ID, Name, Salary, start_date, State,Sex) values (1, 'Ram', 41430, '02/03/86', 'New Delhi', 'M')
(1 rows affected)
Insert into Employee (ID, Name, Salary, start_date, State, Sex) values (2, 'Sohan',12420, '01/02/94', 'New York','M')
(1 rows affected)
Insert into Employee (ID, Name, Salary, start_date, State, Sex) values (3, 'Ceija', 20020, '12/03/90', 'Toronto', 'F')
(1 rows affected)
Insert into Employee (ID, Name, Salary, start_date, State, Sex) values (9,'Mona', 50020, '06/09/03', 'Toronto', 'F')
(1 rows affected)
Insert into Employee (ID, Name, Salary, start_date, State, Sex) values (8, 'Mary', 20020, '07/08/03', 'New York','F')
(1 rows affected)
Insert into Employee (ID, Name, Salary, start_date, State, Sex)values (5, 'James', 70026, '10/05/95', 'Vancouver','M')
(1 rows affected)


select * from Employee


Use AND operator in WHERE clause

SELECT Name, ID FROM Employee WHERE Salary > 20000 AND Salary < 70000


drop table Employee