I need to create a QueryBuilder with union, is that possible ?
$qb = $this->em->createQueryBuilder()
->select('table1.numObject AS id')
->select ('table1.name AS name')
->from("MyBundle:Table1", "table1")
and union
->select('table2.id AS id')
->select ('table2.name AS name')
->from("MyBundle:Table2", "table2")
Note : it has to be a queryBuilder object (not query or something else)
Thank you
Unfortunately UNION
is not possible within Doctrine
. You have to fetch two sets from database and do "union" manually on php side or use native sql.
Check this issue for more information
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With