Toto je váš dotaz:
SELECT c.*, COUNT(d.servername) as servercount, d.controller
FROM customers C JOIN
customerdata d
ON c.id = d.customer
WHERE isVdi = :isVdi AND d.controller = :controller
GROUP BY d.customer
ORDER BY c.name ASC, c.environment ASC;
Bohužel cokoliv = NULL
se nikdy nevrátí pravda. Ještě více bohužel, MySQL nepodporuje ANSI standard NULL
-safe komparátor is not distinct from
. Ale naštěstí má alternativu. Můžete zkusit toto:
SELECT c.*, COUNT(d.servername) as servercount, d.controller
FROM customers C JOIN
customerdata d
ON c.id = d.customer
WHERE isVdi = :isVdi AND
d.controller <=> :controller
GROUP BY d.customer
ORDER BY c.name ASC, c.environment ASC;