如何在SQL Server中使用或操作员 [英] How to use or operater in sql server
本文介绍了如何在SQL Server中使用或操作员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我已经使用过这样的查询.
Hi All,
I have used a query like that.
SELECT *,convert(varchar,DOJ,103) as DateOJ FROM Registration_Mstr R,Designation_Mstr D,Department_Mstr DP where R.DesgId=D.DesgId and DP.DepartmentId=R.DepartmentId and EmployeeStatus=1 and (D.Designation<>'Administrator' or D.Designation<>'Directors') order by EmployeeName
在此,我不想填充指定为管理员和董事的员工的信息.
但它仍在显示信息.
如果我在某个地方错了,请提供帮助.
谢谢
莫哈末Wasif
In this I do not want to populate information of employees whose designation are Administrator and Directors.
But still it is showing information.
Please help if I am wrong somewhere .
Thanks
Mohd. Wasif
推荐答案
请勿使用OR
.仅使用AND
.D.Designation<>''Administrator'' AND D.Designation<>''Directors''
Don''t useOR
. UseAND
only.D.Designation<>''Administrator'' AND D.Designation<>''Directors''
SQL中这种说法的另一种方式是使用IN列表.它们有时可能更容易解释:
Another way of saying this in SQL is to use IN-lists. They may sometimes be more easy to interpret:
SELECT *,convert(varchar,DOJ,103) as DateOJ
FROM Registration_Mstr R,
Designation_Mstr D,
Department_Mstr DP
where R.DesgId = D.DesgId
and DP.DepartmentId = R.DepartmentId
and EmployeeStatus = 1
and D.Designation NOT IN('Administrator','Directors')
order by EmployeeName
and
D.Designation<>'Administrator' or and D.Designation<>'Directors'
这篇关于如何在SQL Server中使用或操作员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文