diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index f097be0114..55e50f32d2 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -106,7 +106,7 @@ function GenGroupSQL($pattern, $search = '', $extra = 0) $pattern = rtrim($pattern, '&|'); - if ($tables[0] != 'devices' && dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?', array($tables[0],'device_id')) != 1) { + if (!in_array('devices', $tables) && dbFetchCell('SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_NAME = ? && COLUMN_NAME = ?', array($tables[0],'device_id')) != 1) { //Our first table has no valid glue, prepend the 'devices' table to it! array_unshift($tables, 'devices'); }