Solved

An SQL Query for a specific executable that is NOT on a machine

Posted on 2011-09-09
3
280 Views
Last Modified: 2012-05-12
I am new to sql queries - I have no problem finding something that IS on a machine, but today I was asked to find machines that do NOT have a specific executable.

In this case, I am only looking for "someprogram.exe" to not be on a machine, and I don't want to see all the programs that are not like "someprogram.exe" because that will list everything on the machines.

How would I write a query to look for something to not be on the machine.

Just to keep it easy - lets say everything is in one table so we don't need to join anything - I just need to know some basic syntax.

Thanks
0
Comment
Question by:pgroth
3 Comments
 
LVL 6

Accepted Solution

by:
mjfagan earned 125 total points
Comment Utility
Check out the IN and EXISTS functions.  You can do NOT IN and NOT EXISTS.

http://www.techonthenet.com/sql/in.php
      
http://www.techonthenet.com/sql/exists.php
      
0
 
LVL 42

Expert Comment

by:dqmq
Comment Utility
select MachineID from yourtable  t1
  where not exists
        (select * from yourtable t2
            where  t2.programname name = 'someprogrem.exe'
                and t2.machineID = t1.machineid)
0
 

Author Closing Comment

by:pgroth
Comment Utility
Thanks - I believe the Exists command should work... not exists specifically.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now