Hi, I'm struggling to express a query in DBIC. I've got the following situation:
table events {
id primary key,
name varchar
}
table sessions {
id primary key,
event references events(id),
starts datetime
}
I have the appropriate DBIx classes set up, including the proper has_many() and belongs_to() relationships. So each event can have multiple sessions. I need a list of events, ordered their earliest start date. The SQL for this
would be:
select e.name, s.starts
from events e
join sessions s on e.id = s.event
join ( select event, min(starts) as starts
from sessions
group by event
) as t
on s.event = t.event
and s.time = t.starts
But how do I convert this to a DBIC expression? I'd appreciate your help
--
Lyon