SELECT c.clientID, c.name, c.address, c.city, c.locality, c.country, c.postal, c.phone, c.fax, c.contactName, c.contactPhone, c.notes, c.active, (select count(*) from #variables.tableprefix#projects p where p.clientID = c.clientID) as numProjects FROM #variables.tableprefix#clients c WHERE 0 = 0 AND clientID = AND c.active = 1 ORDER BY name INSERT INTO #variables.tableprefix#clients (clientID, name, address, city, locality, country, postal, phone, fax, contactName, contactPhone, notes, active ) VALUES ('#createUUID()#', , , , , , , , , , , , ) UPDATE #variables.tableprefix#clients SET name = , address = , city = , locality = , country = , postal = , phone = , fax = , contactName = , contactPhone = , notes = , active = WHERE clientID =