美好的一天,更高效的T-SQL語句
在我們使用SQL作爲我們的數據庫爲我們Solarwinds的產品,我已經寫了一個查詢那只是下面,我只是想知道是否有更有效的時刻執行查詢的方式。
這裏發生了什麼是我們得到不同的值被監測的設備,如果一個條件已經改變,然後提醒它看起來只是WHERE子句是矯枉過正。
所以我想要的是如果AssignmentName = x,如果currentvalue不= ='y'值然後警報。
FROM
CustomPollerStatus INNER JOIN CustomPollerAssignmentView ON CustomPollerStatus.CustomPollerAssignmentID = CustomPollerAssignmentView.CustomPollerAssignmentID
LEFT OUTER JOIN CustomPollers ON CustomPollerAssignmentView.CustomPollerID = CustomPollers.CustomPollerID
LEFT OUTER JOIN Nodes ON CustomPollerAssignmentView.NodeID = Nodes.NodeID)
where AssignmentName = 'a' and currentvalue != '24'
and AssignmentName = 'b' and currentvalue != '1'
and AssignmentName = 'c' and currentvalue != 'RUN'
and AssignmentName = 'd' and currentvalue != 'RUN'
and AssignmentName = 'e' and currentvalue != '72'
and AssignmentName = 'f' and currentvalue != '30'
and AssignmentName = 'g' and currentvalue != '72'
and AssignmentName = 'h' and currentvalue != '30'
and AssignmentName = 'i' and currentvalue != '276'
and AssignmentName = 'j' and currentvalue != '72'
我是新來的TSQL任何知識將是創造
我would'nt覺得這個查詢將返回任何resluts?」 –
你發佈? – Paparazzi