Added unit_count column to ADB Netzgebiet with auto update in Netzgebiet

model
This commit is contained in:
Frank Schubert
2023-04-24 20:31:30 +02:00
parent 145677e2a9
commit d1818a8c96
3 changed files with 23 additions and 1 deletions
@@ -150,3 +150,13 @@ class ADBNetzgebietModel {
}
}
/*
* Update unit_count in Netzgebiet:
UPDATE `Netzgebiet`
LEFT JOIN (SELECT netzgebiet_id, COUNT(*) as uc FROM Wohneinheit LEFT JOIN Hausnummer ON (Wohneinheit.hausnummer_id = Hausnummer.id) GROUP BY netzgebiet_id) AS uc_table ON (uc_table.netzgebiet_id = Netzgebiet.id)
SET unit_count = uc_table.uc
WHERE uc_table.uc IS NOT NULL;
*/