PostgreSQL AND
To filter the results, the PostgreSQL AND condition is used with SELECT, INSERT, UPDATE and DELETE statements to test more than one conditions.
Syntax:
WHERE condition_1 AND condition_2 AND condition_3 …. AND condition_n;
Parameters:
condition_1, condition_2… condition_n: They are used to specify the conditions to be strictly followed for selection.
Example:
Students table:
ID | NAME | AGE |
1 | Joy | 5 |
2 | Smiley | 13 |
3 | Happy | 11 |
4 | Tom | 15 |
5 | Jerry | 10 |
6 | Bruno | 6 |
7 | David | 8 |
Query:
SELECT * FROM “STUDENTS” WHERE “AGE” > 10 AND “AGE” < 15 ORDER BY “NAME”; |
Output:
ID | NAME | AGE |
2 | Smiley | 13 |
3 | Happy | 11 |