2013-08-06 63 views
0

我想顯示查看的最後10個元素。UNION在Doctrine 2中訂購

這是我在SQL查詢:

SELECT compte.dateConsultation AS dateObjet, societe.nom FROM compte, societe WHERE compte.idSociete = societe.id 

UNION 

SELECT opportunite.dateConsultation as dateObjet, opportunite.nom 
FROM opportunite 

UNION 

SELECT contact.dateConsultation as dateObjet, CONCAT(CONCAT(personne.nom, " "),personne.prenom) 
FROM contact, personne 
WHERE contact.idPersonne = personne.id 

UNION 

SELECT piste.dateConsultation as dateObjet, CONCAT(CONCAT(personne.nom, " "),personne.prenom) 
FROM piste, personne 
WHERE piste.idPersonne = personne.id 

UNION 

SELECT tache.dateConsultation as dateObjet, tache.objet 
FROM tache 

UNION 

SELECT evenement.dateConsultation as dateObjet, evenement.objet 
FROM evenement 

ORDER BY dateObjet DESC 

我知道,聯盟不支持的學說。但我需要選擇所有元素並對結果進行orderBy dateConsultation。

回答

0

SELECT * FROM (Your query here -- without the order by) ORDER BY dateObjet DESC