Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Lehre - Unterabfrage in from

Dies ist eine Antwort:

$q = new Doctrine_RawSql();
$q->addComponent('t', 'Tag')
    ->select('{t.name}, {t.count}')
    ->from('(SELECT COUNT(*) as count, t.name,t.idtag
        FROM Tag t
            INNER JOIN Video_Has_Tag v USING(idTag)
        GROUP BY v.idTag
        ORDER BY count DESC
        LIMIT 50) t')
    ->orderBy('name');