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

where从句

  •  1
  • SmartestVEGA  · 技术社区  · 15 年前

    我需要这样做:

    有一个名为table1的表它有一个employee id列,status列只有值1和0,department列有值100101102。

    我想列出状态为0和(状态为1的部门=100)的所有employeeid

    请帮帮我

    2 回复  |  直到 15 年前
        1
  •  6
  •   George Mastros    15 年前
    Where Status = 0 or (Department = 100 And Status = 1)
    
        2
  •  3
  •   Pascal MARTIN    15 年前

    你可以用sql编写你的条件,就像你用英语写的一样 (除非你会使用 or 而不是 and ) :

    select *
    from table1
    where status = 0
        or (status = 1 and department = 100)
    


    这将返还所有员工:

    • 状态为0的
    • 或者有1个状态并且有100个部门