SQL AND
The AND
command is similar the WHERE
command, but you use WHERE
for the first filter statement, and you use AND
for all subsequent filter statements.
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
SELECT
*
FROM
rent_payments
WHERE
dollar_amount > 1800
and building_id = 1;
rent_payments
table
building_id | payment_date | dollar_amount |
---|---|---|
1 | 3/1/2018 | 2000 |
1 | 3/2/2018 | 1500 |
2 | 3/1/2018 | 1800 |
2 | 3/3/2018 | 1900 |
1 | 4/2/2018 | 2000 |
1 | 4/2/2018 | 1500 |
2 | 4/1/2018 | 1800 |
2 | 4/2/2018 | 1900 |
Query results
building_id | payment_date | dollar_amount |
---|---|---|
1 | 3/1/2018 | 2000 |
1 | 4/2/2018 | 2000 |