Harrison Groover Posted January 14, 2015 Report post Posted January 14, 2015 I have a working query (Membership Rule) that gathers computers into a collection based on computer name. I also have a working query that gathers by OS (in this example we will use Windows 7). I have been trying to get the two combined into one query (basically an "and" statement instead of creating two separate membership rules, which apparently is an "or" statement). I readily admit that building queries is not my strongpoint, and I don't even know if this is the proper way to go about it, but I have been tinkering with it quite a bit. Here are the two queries...I know that both of them work individually, but I keep getting syntax errors when I try to combine them. select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_R_System.OperatingSystemNameandVersion like "%Workstation 6.1%" or SMS_R_System.OperatingSystemNameandVersion like "%Windows 7%" and SMS_G_System_COMPUTER_SYSTEM.SystemType = "x64-based PC" select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.NetbiosName like "Example" Is there a way to combine these two statements into one? Any help would be very much appreciated! Quote Share this post Link to post Share on other sites More sharing options...
Peter van der Woude Posted January 14, 2015 Report post Posted January 14, 2015 That shouldn't be to difficult as they are both using the same classes. I think it could be something like this (haven't tested it): select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.SystemType = "x64-based PC" and SMS_R_System.NetbiosName like "Example" and (SMS_R_System.OperatingSystemNameandVersion like "%Workstation 6.1%" or SMS_R_System.OperatingSystemNameandVersion like "%Windows 7%") As you might also notice I've changed the operating system check. This is to assure that both options are valid, although I think that the second option doesn't even exist. Quote Share this post Link to post Share on other sites More sharing options...
Harrison Groover Posted January 14, 2015 Report post Posted January 14, 2015 Peter, you are totally awesome! This works like a charm. Thank you very much! amazing how many different places I stuck that "and" in there without getting it to work lol. Quote Share this post Link to post Share on other sites More sharing options...