How can I build query in search model to select values from table_a
where related table_b
last inserted record is equal to something.
My tables looks something like that
table_a
table_b
At this moment my query in search model looks like that:
TableA::find()->joinWith(['user', 'TableB'])->groupBy(['table_a.id', 'table_b.table_a_id']);
Query generated by ActiveRecord have to give same results like query
SELECT a.* FROM table_a OUTER LEFT JOIN (SELECT status, some_other_status FROM table_b ORDER BY timestamp LIMIT 1) as b ON b.table_a_id = a.id WHERE b.status = X;