0

如何使用 Idiorm 查询重写它?

SELECT *
FROM regioner_financier_correspond as t1
  INNER JOIN (SELECT MAX(t2.id) as maxId
              FROM regioner_financier_correspond as t2
              WHERE `client_code` IN ('03-01', '03-07', '03-08', '03-67')
              GROUP BY t2.client_code) as t3
    ON t1.id=t3.maxId

追加:我试试这个,但它不起作用

$data = \ORM::for_table('regioner_financier_correspond')
            ->select('regioner_financier_correspond.*', 't1')
            ->inner_join('regioner_financier_correspond', array('t1.id', '=', 't3.maxId'), 't2')
            ->where_in('client_code', explode(',', $clients))
            ->group_by('t3.client_code')
            ->find_many();
4

1 回答 1

0

您可以使用raw_query来完成此操作,或者改为使用该ORM::raw_execute函数来执行您提到的原始查询。

于 2015-06-15T12:15:39.807 回答