在Doctrine 2中按UNION命令

时间:2022-08-20 22:48:01

I want to display the 10 last elements viewed.

我想显示最后查看的10个元素。

Here is my query in SQL :

这是我在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

I know that UNION is not supported in Doctrine. But I need to select all elements and do an orderBy dateConsultation on the result.

我知道Doctrine不支持UNION。但我需要选择所有元素并对结果执行orderBy dateConsultation。

1 个解决方案

#1


0  

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

SELECT * FROM(您的查询 - 没有订单)ORDER BY dateObjet DESC

#1


0  

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

SELECT * FROM(您的查询 - 没有订单)ORDER BY dateObjet DESC