→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
08-22-2023 07:16 PM - last edited on 04-01-2024 01:27 PM by Mercedes_O
Hello. I need help with a SQL query I'm trying to run in LS.
End goal: we want to find all machines with Java installed, but NOT include anything that has the SE Development Kit OR a software known as "Ignition". [Has: Java but NOT (SE Development Kit OR Ignition)]
Here's the query as it stands:
Select Top 1000000 tsysOS.Image As icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname As OS,
tblAssets.Username,
tblAssets.Userdomain,
tblAssets.IPAddress,
tblAssets.Firstseen,
tblAssets.Lastseen,
tblAssets.Lasttried,
'black' As foregroundcolor,
tblComputersystem.Domainrole
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysOS On tsysOS.OScode = tblAssets.OScode
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Where tblAssets.AssetID In (Select Top 1000000 tblSoftware.AssetID
From tblSoftware Inner Join tblSoftwareUni On tblSoftwareUni.SoftID =
tblSoftware.softID
Where tblSoftwareUni.softwareName Like 'Java%' And
Not (tblSoftwareUni.softwareName Like '%SE Development Kit%' Or
tblSoftwareUni.softwareName Like 'Ignition%')) And tblAssetCustom.State =
1 And tblComputersystem.domainrole = 1
Order By tblAssets.Domain,
tblAssets.AssetName
TIA
08-22-2023 08:23 PM
Sadly, that did not work. I'm still getting results that have Ignition installed. It seems that it's sufficiently filtering out the Development kit, but not Ignition (which is exactly what was going on before).
08-22-2023 08:26 PM
I added an additional wildcard in the code before Ignition, see if that makes a difference (unforunately we don't use it so I can't test that part).
08-22-2023 08:59 PM
No dice. We're currently researching some option where we do multiple WHERE statements and basically filter out Results B from Results A.
Bleh. I wish I'd taken a SQL class in a former life.
08-22-2023 08:06 PM - edited 08-22-2023 08:25 PM
See if this code will work for you (if an asset has multiple Java versions, it will show up multiple times):
Select Top 1000000 tsysOS.Image As icon,
tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tsysOS.OSname As OS,
tblAssets.Username,
tblAssets.Userdomain,
tblAssets.IPAddress,
tblAssets.Firstseen,
tblAssets.Lastseen,
tblAssets.Lasttried,
'black' As foregroundcolor,
tblComputersystem.Domainrole
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysOS On tsysOS.OScode = tblAssets.OScode
Inner Join tblComputersystem On tblAssets.AssetID = tblComputersystem.AssetID
Inner Join tblSoftware On tblAssets.AssetID = tblSoftware.AssetID
Inner Join tblSoftwareUni On tblSoftwareUni.SoftID = tblSoftware.SoftID
Where tblSoftwareUni.softwareName Like 'Java%' And
tblSoftwareUni.softwareName Not Like '%SE Development Kit%' And
tblSoftwareUni.softwareName Not Like '%Ignition%' And tblAssetCustom.State = 1
And tblComputersystem.domainrole = 1
Order By tblAssets.Domain,
tblAssets.AssetName
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now