WHERE
The WHERE clause specifies any filters to apply to the data. This allows you to select only a subset of the data in which you are interested. Logically the WHERE clause is applied immediately after the FROM clause.
Examples
Select all rows where the id is equal to 3:
Query
SELECT *FROM tblWHERE id = 3;Result
id | name | col1 | col2 | some column name | i | a | b | c | number | number1 | number2----+----------+------+------+------------------+---+----+----+----+--------+---------+--------- 3 | bookmark | 4 | 5 | beta | 2 | 11 | 21 | 31 | 20 | 200 | 2000Select all rows that match the given case-sensitive LIKE expression:
Query
SELECT *FROM tblWHERE name LIKE '%mark%';Result
id | name | col1 | col2 | some column name | i | a | b | c | number | number1 | number2----+----------+------+------+------------------+---+----+----+----+--------+---------+--------- 1 | mark | 1 | 2 | alpha | 1 | 10 | 20 | 30 | 10 | 100 | 1000 3 | bookmark | 4 | 5 | beta | 2 | 11 | 21 | 31 | 20 | 200 | 2000Select all rows that match the given case-insensitive expression formulated with the ILIKE operator:
Query
SELECT *FROM tblWHERE name ILIKE '%mark%';Result
id | name | col1 | col2 | some column name | i | a | b | c | number | number1 | number2----+----------+------+------+------------------+---+----+----+----+--------+---------+--------- 1 | mark | 1 | 2 | alpha | 1 | 10 | 20 | 30 | 10 | 100 | 1000 3 | bookmark | 4 | 5 | beta | 2 | 11 | 21 | 31 | 20 | 200 | 2000Select all rows that match the given composite expression:
Query
SELECT *FROM tblWHERE id = 3 OR id = 7;Result
id | name | col1 | col2 | some column name | i | a | b | c | number | number1 | number2----+----------+------+------+------------------+---+----+----+----+--------+---------+--------- 3 | bookmark | 4 | 5 | beta | 2 | 11 | 21 | 31 | 20 | 200 | 2000 7 | other | 9 | 16 | gamma | 3 | 12 | 22 | 32 | NULL | 300 | 3000