0

How can I rewrite this using an Idiorm query?

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

Append: I try this, but it's doesn't works

$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 に答える