SQL Statements simplified and some bugfixing

This commit is contained in:
2023-02-15 12:44:29 +01:00
parent ed33c0553d
commit 6df7a3f6a8
38 changed files with 694 additions and 678 deletions

View File

@@ -42,24 +42,20 @@
// setup subnet
// build query
$query = "SELECT
subnet.subnet_address,
subnet.subnet_mask,
subnet.subnet_dhcp_start,
subnet.subnet_dhcp_end,
subnet.subnet_info,
subnet.protocol_version,
subnet.ntp_server,
s.subnet_address,
s.subnet_mask,
s.subnet_dhcp_start,
s.subnet_dhcp_end,
s.subnet_info,
s.protocol_version,
s.ntp_server,
COUNT(node.subnet_id) AS node_counter
FROM
subnet
LEFT JOIN
node
ON
node.subnet_id=subnet.subnet_id
subnet AS s LEFT JOIN node USING (subnet_id)
WHERE
subnet.subnet_id=" . $subnet_id . "
s.subnet_id=" . $subnet_id . "
GROUP BY
subnet.subnet_id";
s.subnet_id";
// run query
$subnet = $db->db_select($query);
@@ -394,18 +390,14 @@
// setup location
// build query
$query = "SELECT
location.location_id,
location.location_name
l.location_id,
l.location_name
FROM
location
LEFT JOIN
subnetlocation
ON
subnetlocation.location_id=location.location_id
location AS l LEFT JOIN subnetlocation AS s USING (location_id)
WHERE
subnetlocation.subnet_id=". $subnet_id . "
s.subnet_id=". $subnet_id . "
ORDER BY
location.location_name";
l.location_name";
// run query
$locations = $db->db_select($query);