The obvious solution — using findCount() — doesn’t work, as there is no way to specify that you want to use “distinct”.
So to get the desired result we have to use a find() or findAll() statement as shown in the following example:
$this->User->find(null, "COUNT(DISTINCT User.city) AS 'count'");
沒有留言:
張貼留言