PostgreSQL AND Keyword
The PostgreSQL AND keyword is used to combine multiple conditions in a PostgreSQL WHERE clause and displays a record if all the conditions separated by AND keyword are true.
Syntax
The syntax for using AND keyword in PostgreSQL is given below:
SELECT column1, column2, column3, ... FROM table_name WHERE condition1 AND condition2 AND condtion3 ....;
Example:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age | Salary |
---|---|---|---|---|
1 | John | London | 25 | 3000 |
2 | Marry | New York | 24 | 2750 |
3 | Jo | Paris | 27 | 2800 |
4 | Kim | Amsterdam | 30 | 3100 |
5 | Ramesh | New Delhi | 28 | 3000 |
6 | Huang | Beijing | 28 | 2800 |
-
To select all records of the Employee table where Salary is greater than 2800 and Age is less than 30, the query is mentioned below.
SELECT * FROM Employee WHERE Salary > 2800 AND Age < 30;
This result of the following code will be:
EmpID Name City Age Salary 1 John London 25 3000 5 Ramesh New Delhi 28 3000
❮ PostgreSQL Keywords