Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Groupwise maximum
  • In my database I have authors and articles. I'm trying to get the latest article for each author. This is simple using the query builder, where I just add a left join and a where. For example:
    select a1.title from article a1
    left join article a2 on a2.author_id = a1.author_id and a2.time > a1.time
    where a2.article_id is null;
    

    I would prefer to do this with ORM since there are a lot of related records I also need to retrieve. I got it working using a dependent subquery but it was too slow because there are too many records. Is there a way I can make a query like the one above using ORM, or any other way I can achieve this? Thanks

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!