diff --git a/includes/html/pages/devices.inc.php b/includes/html/pages/devices.inc.php
index 452b9b6c05..c5c9b2f033 100644
--- a/includes/html/pages/devices.inc.php
+++ b/includes/html/pages/devices.inc.php
@@ -202,7 +202,7 @@ if ($format == "graph") {
$where .= " )";
}
- $query = "SELECT * FROM `devices`,locations WHERE devices.location_id = locations.id ";
+ $query = "SELECT * FROM `devices` LEFT JOIN `locations` ON `devices`.`location_id` = `locations`.`id` WHERE 1";
if (isset($where)) {
$query .= $where;