ManytoMany实体选择查询原则

I am trying to run a query. I have two many to many entities.

My query for these both entities below

  $query = $user->createQueryBuilder('u')
              ->join('u.products', ua')
              ->Where('ua.id In (:uproducts)')
              ->setParameters(array(
                  'uproducts' => $userproducts ))
              ->getQuery();

              $query = $user->createQueryBuilder('u')
                  ->join('u.price,'up')
                  ->Where('up.id In (:uprice)')
                  ->setParameters(array(
                      'uprice'=>$userprice))
                  ->getQuery();

If i do that in two queries like that it works. But I want that in 1 select query. Is there any idea how I could do that?

Thanks in advance.

Try this :

$query = $user->createQueryBuilder('u')
          ->join('u.products', 'ua')
          ->join('u.price,'up')
          ->Where('ua.id In :uproducts')
          ->andWhere('up.id In :uprice')
          ->setParameters(
             array (
                'uproducts' => $userproducts,
                'uprice'=>$userprice 
              ) 
            )
          ->getQuery();