我需要SQL查询的帮助。我正在查询我的活动目录,我需要忽略所有将其manager字段设置为null的对象,除非该对象具有某个名称。我不太确定如何执行我需要的UNLESS声明。以下是我到目前为止的情况:
SELECT distinguishedName AS UniqueId,
department,
Title,
Manager AS ManagerId,
displayName AS Name,
mail AS Email,
thumbnailphoto AS photo
FROM OPENQUERY(ADSI,'SELECT mail,
CN,
distinguishedName,
Manager,
displayName,
Title,
department,
thumbnailphoto FROM
''LDAP://internal.mesacounty.us'
'WHERE objectCategory=''Person'' AND
objectClass = ''User''') AS derivedtbl_1
WHERE (Manager IS NOT NULL ***UNLESS DisplayName = ''WHATEVER NAME I CHOOSE'')
答案 0 :(得分:2)
用UNLESS
替换OR
应该这样做。