You can simply use :

$this->Shipment->query("

SELECT *, COUNT(`tank_id`) AS NumOccurrences FROM `shipments` LEFT 
JOIN `tanks` ON (`shipments`.`tank_id` = `tanks`.`id`) 
GROUP BY `tank_id` 
HAVING ( COUNT(`tank_id`) > 1 )

;" );



--
View this message in context: 
http://cakephp.1045679.n5.nabble.com/Help-with-Complex-SQL-FIND-COUNT-tp4498224p4501735.html
Sent from the CakePHP mailing list archive at Nabble.com.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to