zabbix4.0sql

根据主机名获取主机群组名称

#各表查询

select hostid from hosts where name = 'HZSCP25';
select groupid from hosts_groups where hostid = '24997';
select name from hstgrp where groupid = '351';

#子查询

select name from hstgrp where groupid = (select groupid from hosts_groups where hostid = (select hostid from hosts where name = 'HZSCP25'));

#where
select c.name from hosts as a,hosts_groups as b,hstgrp as c where c.groupid = b.groupid and a.hostid = b.hostid and a.name = 'HZSCP25';

#inner jion
select c.name from (hstgrp as c inner jion hosts_groups as b ON c.groupid = b.groupid) inner jion hosts as a ON a.hostid = b.hostid and a.name = 'HZSCP25';
原文地址:https://www.cnblogs.com/banxiancode/p/12618398.html