Mysql
 sql >> Base de données >  >> RDS >> Mysql

Instruction préparée PHP PDO bind valeur NULL

Voici votre requête :

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;

Malheureusement, n'importe quoi = NULL ne reviendra jamais vrai. Encore plus malheureusement, MySQL ne supporte pas la norme ANSI NULL -le comparateur sécurisé is not distinct from . Mais heureusement, il a une alternative. Vous pouvez essayer ceci :

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;