Fix clients being duplicated when multiple tags are assigned to them

This commit is contained in:
johnnyq 2023-03-05 11:40:20 -05:00
parent 5640a22c18
commit cdf97ec83b
1 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@ $url_query_strings_sb = http_build_query(array_merge($_GET, array('sb' => $sb, '
$sql = mysqli_query(
$mysqli,
"SELECT DISTINCT SQL_CALC_FOUND_ROWS clients.*, contacts.*, locations.*, tags.* FROM clients
"SELECT DISTINCT SQL_CALC_FOUND_ROWS * FROM clients
LEFT JOIN contacts ON clients.primary_contact = contacts.contact_id AND contact_archived_at IS NULL
LEFT JOIN locations ON clients.primary_location = locations.location_id AND location_archived_at IS NULL
LEFT JOIN client_tags ON client_tags.client_tag_client_id = clients.client_id
@ -21,7 +21,7 @@ $sql = mysqli_query(
AND client_archived_at IS NULL
AND DATE(client_created_at) BETWEEN '$dtf' AND '$dtt'
AND clients.company_id = $session_company_id
GROUP BY clients.client_id, contacts.contact_id, locations.location_id, client_tags.client_tag_tag_id, tags.tag_id
GROUP BY clients.client_id
ORDER BY $sb $o LIMIT $record_from, $record_to
");