.. _sql_where: WHERE function ^^^^^^^^^^^^^^ **Supported datatypes:** :ref:`TINYINT`, :ref:`SMALLINT`, :ref:`INT`, :ref:`BIGINT`, :ref:`DECIMAL`, :ref:`FLOAT`, :ref:`DOUBLE` :ref:`TIMESTAMP`, :ref:`VARCHAR`, :ref:`BOOLEAN` Filter returned rows from a table. The following operators are supported in :code:`WHERE` statements: :ref:`comparison` , :ref:`logical`, and :ref:`IN operators` and :ref:`IS operators`. Examples """""""" Comparison operators ~~~~~~~~~~~~~~~~~~~~ These include operators like `less than` or `equal to`. Refer to :ref:`comparison operators` for a full list of supported syntax. .. code-block:: sql SELECT * FROM WHERE = .. code-block:: sql SELECT * FROM WHERE <= Selecting rows can also be done by comparing values in columns with comparable data types: numeric with numeric, timestamp with timestamp , string with string (only :code:`=` is supported). .. code-block:: sql SELECT * FROM WHERE >= Logical operators ~~~~~~~~~~~~~~~~~ When using the :code:`WHERE` statement rows are selected where the predicate for the row evaluates to :code:`TRUE`: in first the example above only rows where :code:`col_1` are equal to some :code:`number` will be selected. These statements can be further *chained* to create more complex logical statements. .. code-block:: sql SELECT * FROM WHERE => AND <= .. code-block:: sql SELECT * FROM WHERE BETWEEN AND OR <= Refer to :ref:`logical operators` for a full list of supported syntax. :code:`IN` operators ~~~~~~~~~~~~~~~~~~~~ Filtering data to some subset of allowed values can be achieved with :code:`IN` operators. .. code-block:: sql SELECT * FROM WHERE IN (, ) The above example is an equivalent to: .. code-block:: sql SELECT * FROM WHERE = OR = To select all the rows but those that are equal to :code:`string_1` or :code:`string_2`, the :code:`IN` statement can be negated: .. code-block:: sql SELECT * FROM WHERE NOT IN (, ) If the list of strings is long a subquery can be included within the parentheses: .. code-block:: sql SELECT * FROM WHERE IN ( SELECT FROM WHERE >= ) Refer to :ref:`IN operators` for a full list of supported syntax. :code:`IS` operators ~~~~~~~~~~~~~~~~~~~~~ Filtering data using :code:`BOOLEAN` columns can be achieved by simply passing the column itself (or its negation) as a predicate: .. code-block:: sql SELECT * FROM WHERE .. code-block:: sql SELECT * FROM WHERE NOT The first example above code is equivalent to .. code-block:: sql SELECT * FROM WHERE IS TRUE or .. code-block:: sql SELECT * FROM WHERE IS NOT FALSE Refer to :ref:`IS operators` for a full list of supported syntax.