T-SQL Tutorial T-SQL Advanced Database Management T-SQL References

T-SQL - AND Operator



The T-SQL (Transact-SQL) AND Operator is used to combine multiple conditions in a WHERE clause of T-SQL statement. It displays a record if all the conditions separated by AND operator are true.

Syntax

The syntax for using AND operator in T-SQL (Transact-SQL) is given below:

SELECT column1, column2, column3, ...
FROM table_name
WHERE condition1 AND condition2 AND condtion3 ....;

Example:

Consider a database containing a table called Employee with the following records:

EmpIDNameCityAgeSalary
1JohnLondon253000
2MarryNew York242750
3JoParis272800
4KimAmsterdam303100
5RameshNew Delhi283000
6HuangBeijing282800

  • To select all records of the Employee table where Salary is greater than 2800 and Age is less than 30, the query is given below.

    SELECT * FROM Employee
    WHERE Salary > 2800 AND Age < 30;
    

    This will produce the result as shown below:

    EmpIDNameCityAgeSalary
    1JohnLondon253000
    5RameshNew Delhi283000

❮ T-SQL - Operators