where clause from where clause

寵の児 提交于 2020-01-05 06:57:15

问题


i need to do this :

There is a table called table1 it has a employee id column,status column which has values 1 and 0 only and a department column with values 100,101,102.

i want to list all employeeid with the status = 0 and (department=100 whose status=1)

Please help me


回答1:


Where Status = 0 or (Department = 100 And Status = 1)



回答2:


You can write your condition in SQL almost like you wrote it in english (except you'll use a or instead of a and) :

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


This will return all employees :

  • that have a 0 status
  • or have a 1 status and have departement 100


来源:https://stackoverflow.com/questions/2419043/where-clause-from-where-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!