我想显示最后查看的10个元素。
这是我在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
我知道,Doctrine不支持UNION。但是我需要选择所有元素并对结果执行orderBy dateConsultation。
最佳答案
SELECT * FROM (Your query here -- without the order by) ORDER BY dateObjet DESC
关于mysql - 在学说2中按UNION订购,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18081503/