从
g5ch3_empstatus_objects
选择es。*作为es
内部联接(选择 statuscreator,statuscreatorid,max(created)as maxcreated,ustatus fromg5ch3_empstatus_objects
其中statuscreator ='user-> name'group by 在es.statuscreator上的statuscreators = s.statuscreator和 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);
}
答案 0 :(得分:0)
转到http://docs.joomla.org/Accessing_the_database_using_JDatabase/2.5并查看“从多个表中选择记录”部分。