使用cakephp自我加入

时间:2011-01-29 03:42:43

标签: sql cakephp-1.3

我怎样才能在cakephp中编写这个sql查询

select name from coupons as c where c.created=(select max(c2.created) from coupons as c2);

1 个答案:

答案 0 :(得分:1)

在这种情况下,也许你真的是这个意思:

$this->Coupon->find('first', array('order' => array('Coupon.created' => 'desc')));

对于真正的子查询,see the manual under Subqueries