SQL gives us the power to choose what data we pull out of our table. We will use the where clause within our select statement with many operators. These include the greater than, less than, equal, and not equal. We will also use some special operators such as "in", "between", and "is".
not equal:
$ postgres=# select * from Users where create_date <> '2018-05-05';
is:
$ postgres=# select * from Users where first_name is null;
create_date | user_handle | last_name | first _name --------------+--------------------------------------+-----------+------------- 2018-08-06 | fw1kv3z4-fk98-pl2f-se48-f823jfhaj39f | | (1 row )
If you use =
$ postgres=# select * from Users where first_name = null; create_date | user_handle | last_name | first _name --------------+--------------------------------------+-----------+------------- (0 rows ) $ postgres=#
between:
$ postgres=# select * from Users where create_date between '2018-05-01' and '2018-07-01'; create_date | user_handle | last_name | first _name --------------+--------------------------------------+-----------+------------- 2018-06-06 | 2839f831-f82c-faj3-aof3-fj28ddks39ek | clark | tyler 2018-06-06 | 6ab3b2d2-8e02-890c-bb6d-61a67cd43f31 | jones | debbie (2 rows ) $ postgres=#
in:
$ postgres=# select * from Users where last_name in ('clark', 'jones'); create_date | user_handle | last_name | first _name --------------+--------------------------------------+-----------+------------- 2018-06-06 | 2839f831-f82c-faj3-aof3-fj28ddks39ek | clark | tyler 2018-06-06 | 6ab3b2d2-8e02-890c-bb6d-61a67cd43f31 | jones | debbie (2 rows ) $ postgres=#