I am building a query in CakePHP, but cannot use a GROUP BY
statement in my find('count')
as it throws an error. Therefore I used instead of the GROUP BY
statement a DISTINCT
field in my fieldlist.
So, from find('count', array('group' => 'field'))
I now have find('count', array('fields' => 'DISTINCT field'))
In another part of the application, I am using a find('all')
to fetch the same records as above. Here, I am able to use the GROUP BY
statement, so I have:
find('all', array('group' => 'field'))
My question is: are both of the queries described above returning the same results? Briefly I want to be sure that DISTINCT field
combined with find('count')
returns the same results as GROUP BY field
combined with find('all')
.