diff --git a/user/assets.php b/user/assets.php
index e0df482a..a06e29be 100644
--- a/user/assets.php
+++ b/user/assets.php
@@ -230,10 +230,8 @@ if (mysqli_num_rows($os_sql) > 0) {
$sql_locations_filter = mysqli_query($mysqli, "
SELECT DISTINCT location_id, location_name
FROM locations
- LEFT JOIN assets ON asset_location_id = location_id
WHERE location_client_id = $client_id
- AND location_archived_at IS NULL
- AND (asset_location_id != 0 OR location_id = $location_filter)
+ AND ( EXISTS (SELECT 1 FROM assets WHERE asset_location_id = location_id AND $archive_query) OR location_id = $location_filter)
ORDER BY location_name ASC
");
while ($row = mysqli_fetch_array($sql_locations_filter)) {
diff --git a/user/clients.php b/user/clients.php
index 9a64d587..faf31ea2 100644
--- a/user/clients.php
+++ b/user/clients.php
@@ -250,7 +250,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
@@ -269,7 +269,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
diff --git a/user/contacts.php b/user/contacts.php
index 12d22069..fb30f013 100644
--- a/user/contacts.php
+++ b/user/contacts.php
@@ -163,10 +163,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
$sql_locations_filter = mysqli_query($mysqli, "
SELECT DISTINCT location_id, location_name
FROM locations
- LEFT JOIN contacts ON contact_location_id = location_id
WHERE location_client_id = $client_id
- AND location_archived_at IS NULL
- AND (contact_location_id != 0 OR location_id = $location_filter)
+ AND ( EXISTS (SELECT 1 FROM contacts WHERE contact_location_id = location_id AND $archive_query) OR location_id = $location_filter)
ORDER BY location_name ASC
");
while ($row = mysqli_fetch_array($sql_locations_filter)) {
diff --git a/user/expenses.php b/user/expenses.php
index 75e476a1..484c6756 100644
--- a/user/expenses.php
+++ b/user/expenses.php
@@ -154,7 +154,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- All Categories -
- All Accounts -
- All Categories -
- All Accounts -
- All Payment Methods -
diff --git a/user/products.php b/user/products.php
index 26860cd5..cf936332 100644
--- a/user/products.php
+++ b/user/products.php
@@ -91,7 +91,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- All Accounts -
- All Accounts -