/bundles/itninjaweb/img/Breadcrumb_cap_w.png
I have a query where I want to add a smart label for all machines in a given ip range, but exclude those that start with TC.  
It works successfully on the IP range but it still includes those with names that start with TC
here is an excerpt from my query:
OR (1 in (select 1 from ORG1.MACHINE M2 where M2.ID = MACHINE.ID and M2.IP like '%172.16.12.%' union select 1 from ORG1.MACHINE_NICS where MACHINE.ID = MACHINE_NICS.ID and MACHINE_NICS.IP like '%172.16.12.%' and MACHINE.NAME not like '%TC%' ))  )
0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Community Chosen Answer


Answers

1
Your query is much more complicated than it needs to be. This should work:
SELECT MACHINE.NAME AS SYSTEM_NAME, SYSTEM_DESCRIPTION, MACHINE.IP, MACHINE.MAC, MACHINE.ID as TOPIC_ID FROM MACHINE  WHERE MACHINE.IP like "172.16.12.%" and MACHINE.NAME not like "TC%"


Answered 02/07/2018 by: chucksteel
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity

Answers

0

Try this for your SQL Code.

SELECT MACHINE.NAME AS SYSTEM_NAME,SYSTEM_DESCRIPTION, MACHINE.IP, MACHINE.MAC, MACHINE.ID as TOPIC_ID FROMMACHINE  WHERE ((MACHINE.IP like '172.16.12.%') AND ((MACHINE.NAME notlike 'TC%'))) 

You could also open yourInventory>Devices section, choose the Smart Label tab to create a smartlabel from manual Advanced searches.  Choose your first line to filteryour IP to IP Address Begins with 172.16.12. then click Add Group and in that newgroup, choose a filter for System Name Does NOT begin with TC.  Save thatlabel and it should work as well.

Answered 02/07/2018 by: DaveMT
Third Degree Black Belt

Please log in to comment

Share