zoukankan      html  css  js  c++  java
  • [Postgres] Conditionally Select out Filtered Data with SQL Where

    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=#
  • 相关阅读:
    模板类 & 虚函数
    Page Color (页面着色)
    修改静态库
    ElementUI 时间选择器
    自定义export
    vue组件
    ElementUI 表格
    ElementUI 分页
    数组方法分类
    Vue过滤数组副本
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13599708.html
Copyright © 2011-2022 走看看