Hi,
I am trying to query in QueryBuilder using COALESCE in a where clause with a
subquery as one of the COALESCE parameters. As soon as I am replacing the
subquery with a string it works. So far as I can see there is no way to get
a subquery within COALESCE to execute. Am I wrong? What is the suggested way
for such a query?
The desired query is:
SELECT id FROM post mainTable
WHERE (mainTable.modified_at >
COALESCE((SELECT nr.read_at FROM newsread nr WHERE nr.created_by = 34 AND
nr.type = 'post'),'1000-01-01'))
This is my query builder definition:
$qb2 = $em->createQueryBuilder();
$qb2->select(array("nr.read_at"));
$qb2->from('NewsreadEntity','nr');
$qb2->andWhere( 'nr.creator = :user_id2');
$qb2->andWhere( 'nr.type = :type2');
$qb->select(array('partial mainTable.{id}'));
$qb->from('PostEntity','mainTable','mainTable.id');
$qb->andWhere( 'mainTable.modified_at > COALESCE(('.
$qb2->getDQL().'),\'1000-01-01\')');
$qb->setParameter('user_id2',$this->getLoggedInUserId());
$qb->setParameter('type2','post');
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.