Inner Join with select columns model

Hi everybody,

I'm new in Phalcon and I don't know how to translate this query to Phalcon Query, It tooks me 3 hours with many searchs.

select sp.* FROM subplan sp INNER JOIN (SELECT subid, MAX(enddate) AS MaxDateTime FROM subplan WHERE status = 3 GROUP BY subid) groupedtt ON sp.subid = groupedtt.subid AND sp.enddate = groupedtt.MaxDateTime

Can anyone help me with that? Thank you!



I don't think it is possible to do that with phalcon's ORM or query builder. You will have to do that with raw sql.

Just rewrite it to just join table and do WHERE condition on select, not in join.