代码之家  ›  专栏  ›  技术社区  ›  Rbell

相似函数中的多个条件

  •  0
  • Rbell  · 技术社区  · 7 年前

    我有一组数据,每个点要么以 AB , PO LV . 还有很多我不喜欢的东西 MC BV . 我也有一些约会,看起来像这样。

    Select distinct clm.Theletter, clm.thenotedate, clm.theorigdate
    from table.table
    where clm.thenotedate>= ''2018-01-21'' and clm.theorigdate>''2018-01-01'' 
    and clm.Theletter_NUM LIKE ''HP%''
    order by clm.thenotedate asc
    );
    

    我得到了一张我想要的所有东西的清单 AB公司 ,但我也想要 人事军官 低压 ? 我尝试在我的第一个LIKE之后使用OR,但它似乎忽略了日期函数,并检索了2018-01-01之前以 人事军官 低压 ,这是很多。

    2 回复  |  直到 7 年前
        1
  •  2
  •   Gordon Linoff    7 年前

    如果您这样做,这可能是最简单的:

    . . . and
    left(clm.Theletter_NUM, 2) in ('AB', 'PO', 'LV')
    

    大多数数据库支持 left() 字符串上的函数。如果没有,只需使用适当的子字符串函数。

        2
  •  0
  •   Mr Halcolo    7 年前

    您需要在第一个like之后再次写入行的名称。

    Select *
    From table
    Where row like 1 or row like 2
    

    或者您可以在中使用

    Where row in ('1', '2', '3')