select es.* from
g5ch3_empstatus_objects
ases
inner join(select statuscreator,statuscreatorid,max(created)as maxcreated, usstatus fromg5ch3_empstatus_objects
where statuscreator='user->name' group by statuscreator )s on es.statuscreator=s.statuscreator and es.created= s.maxcreated
如何在使用 joomla2.5 的 Joomla 模型类中编写此查询
我已经尝试过这种方式,但我得到了空的结果集:
$query = $db->getQuery(true);
$subquery = $db->getQuery(true);
$subquery->select('max(created) as maxcreated')
-> from ('#_empstatus_objects');
$query->select(
'es.id as id,' .
'es.statuscreator,' .
'es.statuscreatorid,' .
'es.created,' .
'es.ustatus'
);
$query->from ('#__empstatus_objects as es'.$subquery.$where)
-> group('statuscreator');
$superadmin = $this->access_superuser($user->id);
if(!$superadmin){
$query->where ('statuscreatorid='.$user->id);
}