SELECT HOST, hosts.name AS host_name, items.name AS item_name, items.itemid, hstgrp.name AS group_name, history.value ASVALUE FROM `hosts` JOIN hosts_groups ON hosts_groups.hostid = hosts.hostid JOIN hstgrp ON hosts_groups.groupid = hstgrp.groupid JOIN items ON items.hostid = hosts.hostid JOIN history ON h1.itemid = items.itemid WHERE hosts.host = "10.203.4.23" AND h1.clock > UNIX_TIMESTAMP(NOW()) -3*60 UNION SELECT HOST, hosts.name AS host_name, items.name AS item_name, items.itemid, hstgrp.name AS group_name, history_uint.value FROM `hosts` JOIN hosts_groups ON hosts_groups.hostid = hosts.hostid JOIN hstgrp ON hosts_groups.groupid = hstgrp.groupid JOIN items ON items.hostid = hosts.hostid JOIN history_uint ON h2.itemid = items.itemid WHERE hosts.host = "10.203.4.23" AND h2.clock > UNIX_TIMESTAMP(NOW()) -3*60 ORDERBY item_name