Created
November 22, 2012 13:14
-
-
Save cohan/4131121 to your computer and use it in GitHub Desktop.
Zabbix (1.8) - MySQL query to select hosts NOT IN a specific group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Not in a single group: | |
SELECT host FROM hosts h | |
WHERE NOT EXISTS | |
(SELECT groupid FROM hosts_groups hg | |
WHERE h.hostid = hg.hostid | |
AND hg.groupid = 100100000000001); | |
# Not in multiple groups: | |
SELECT host FROM hosts h | |
WHERE NOT EXISTS | |
(SELECT groupid FROM hosts_groups hg | |
WHERE h.hostid = hg.hostid | |
AND hg.groupid IN (100100000000001,100100000000002,100100000000003,100100000000004,100100000000005) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment