Det här är din fråga:
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;
Tyvärr, allt = NULL
kommer aldrig att återvända sant. Ännu mer tyvärr stöder inte MySQL ANSI-standarden NULL
-safe comparator is not distinct from
. Men lyckligtvis har den ett alternativ. Du kan prova detta:
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;