Did you try to google it?

http://www.symfony-project.org/cookbook/1_2/en/retrieving_data_with_doctrine#chapter_f6fc97d827760d5157133eaf9798ddaf_sub_queries
http://www.doctrine-project.org/documentation/manual/1_1/en/dql-doctrine-query-language:subqueries
http://groups.google.com/group/doctrine-user/browse_thread/thread/cfa13d4beebaccaf


On 15 bře, 17:44, "NOOVEO - Christophe Brun" <c.b...@nooveo.fr> wrote:
> I'm trying to create a query like this one :
>
> select commande_id, statut_commande_id, id from historique_commande h
> where h.id = (select max(j.id) from historique_commande j where
> j.commande_id = h.commande_id group by j.commande_id)
> having h.statut_commande_id = 1
> ;
>
> This is to be used as a table_method for a backend list.
>
> I tried this :
> $alias = $q->getRootAlias();
> $q->where("$alias.id = (select max(j.id) from historique_commande j
> where j.commande_id = $alias.commande_id group by j.commande_id)")
>   ->having("$alias.StatutsCommandes.statut_commande_id = ?",
> StatutCommande::DEMANDE_DEVIS);
>
> but it fails : error 500, couldn't find class j.
>
> And :
> $alias = $q->getRootAlias();
> $q->where("$alias.id = (select max(id) from historique_commande where
> commande_id = $alias.commande_id group by commande_id)")
>   ->having("$alias.StatutsCommandes.statut_commande_id = ?",
> StatutCommande::DEMANDE_DEVIS);
>
> leads to : error 500, unknown colum commande_id.
>
> I'm stuck with this, any help would be greatly appreciated !

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to