我最近在我的表格中添加了一个Deleted
列,然后想要添加一个额外的where子句,但现在我没有得到任何结果(它在我添加deleted
之前返回了结果列)
SELECT
tblEquipment.*, tblUsers.*
FROM
tblEquipment
INNER JOIN
tblUsers ON tblEquipment.UserID = tblUsers.ID
WHERE
(UPPER(tblUsers.Dept) = 'ASPIRE' OR UPPER(tblUsers.Dept) = 'DEVELOPMENT')
AND (AssetType = 'WORKSTATION' OR AssetType = 'LAPTOP')
AND (tblEquipment.Deleted != 1)
ORDER BY
Username
感谢您的帮助
答案 0 :(得分:2)
如果每条记录Deleted
为NULL
,则您的条件应为:
AND (tblEquipment.Deleted != 1 OR tblEquipment.Deleted IS NULL)
答案 1 :(得分:1)
我假设您没有填充新列,因此每条记录都有NULL作为值。
取决于RDMS如何评估NULLtblEquipment.Deleted != 1
可能是罪魁祸首。
更新:
以下内容应解决您的问题:
ISNULL(tblEquipment.Deleted,0) != 1