select c.name, lastname, city, zip, address, count(n.id), n.name, passwd FROM customers c LEFT JOIN nodes n ON n.ownerid = c.id GROUP BY c.id;