我怎样才能在cakephp中编写这个sql查询
select name from coupons as c where c.created=(select max(c2.created) from coupons as c2);
答案 0 :(得分:1)
在这种情况下,也许你真的是这个意思:
$this->Coupon->find('first', array('order' => array('Coupon.created' => 'desc')));
对于真正的子查询,see the manual under Subqueries。