Answer the question
In order to leave comments, you need to log in
Doctrine how to get divergence of two queries?
Hello. Essence of the question.
There are two selects, you need to get their discrepancy.
I do so:
On pure SQL everything works, everything is fine. And now the same on DQL.
But the doctrine does not know how. Which option ... we do this:
SELECT * FROM tbl1 EXCEPT SELECT * FROM tbl2
$query1 = $this->em->createQueryBuilder()
->select('c')
->form(MyClass::class, 'c')
->getQuery()
->getDQL();
$query2 = this->em->createQueryBuilder()
->select('c')
->form(OtherMyClass::class, 'c')
->getQuery()
->getDQL();
$dql = $query1 . ' EXCEPT ' . $query2;
$this->em
->createQuery($dql)
->getResult();
Answer the question
In order to leave comments, you need to log in
I do it like this:
SELECT * FROM tbl1 EXCEPT SELECT * FROM tbl2
SELECT t1.*
FROM tbl1
LEFT JOIN tbl2 ON tbl1.primary_key = tbl2.primary_key
WHERE t2.primary_key IS NULL
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question