Replace LEFT JOIN with EXISTS

This commit is contained in:
Laurent Destailleur
2022-10-22 00:22:54 +02:00
parent a2d9dd3388
commit f87ec74b9f
4 changed files with 52 additions and 10 deletions

View File

@@ -109,9 +109,7 @@ class CommandeStats extends Stats
}
if ($categid) {
$this->join .= ' LEFT JOIN '.$this->categ_link.' as cats ON cats.fk_soc = c.fk_soc';
$this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie';
$this->where .= ' AND cat.rowid = '.((int) $categid);
$this->where .= ' AND EXISTS (SELECT rowid FROM '.$this->categ_link.' as cats WHERE cats.fk_soc = c.fk_soc AND cats.fk_categorie = '.((int) $categid).')';
}
}