Question

I couldnt find a clear answer to this questions, should be a simple one. Basically I am trying to get all computers that dont have word installed. This query seems to be giving me wrong data. Any ideas? Thanks!

 SELECT DISTINCT Name
 FROM  dbo.vComputer AS v
 WHERE Name NOT IN 
                 (
                   SELECT Name
                   FROM dbo.vComputer
                   WHERE (dbo.vComputer.installedsoftware LIKE N'%word%')))
Was it helpful?

Solution

Try like this

With NOT EXISTS

SELECT Name
FROM  dbo.vComputer AS V
WHERE NOT EXISTS
                 (
                   SELECT Name
                   FROM dbo.vComputer AS S
                   WHERE S.installedsoftware LIKE N'%word%'
                 )

WITH NOT IN

SELECT Name
FROM dbo.vComputer AS V
WHERE Name NOT In 
               (SELECT Name 
                FROM dbo.vComputer AS S 
                WHERE S.installedsoftware LIKE N'%word%'
               );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top