Sometimes you have to use SELECT DISTINCT to get the desired records from the database. How can you use SELECT DISTINCT with CakePHP?
The solution is rather simple:
$this->User->findAll(null, 'DISTINCT User.city');
Or with the array syntax:
$this->User->findAll(null, array('DISTINCT User.city'));
Please notice that the keyword “DISTINCT” has to be uppercase, else you will get the following error:
Unknown column 'distinct User.city'

How do you use DISTINCT in findCount()?
@Mandy: It is not possible, you have to use a custom query.
@cakebaker: on irc, gwoo said its possible using the array fields. also we could perhaps use find() and pass in count as condition.
[...] post is the answer to Mandy Singh’s comment to the article Select distinct with CakePHP in which he asked how to use “count” with “distinct”. The answer I gave [...]
@Mandy: See http://cakebaker.42dh.com/2007/08/06/using-distinct-and-count-with-cakephp/
Hi folks,
I stumbled upon this post when looking for a way to find(‘list’) with distinct values.
Here’s how I solved it in the end:
http://blog.pepa.info/php-html-css/cakephp/populating-a-select-box-with-distinct-values/
@Petr: Thanks for sharing your solution!