2

Can somebody help me with this problem. I have two table joined like this:

class Splittest { /** * @ORM\ManyToMany(targetEntity="Landing") * @ORM\JoinTable(name="splittest_landings", * joinColumns={@ORM\JoinColumn(name="splittest_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="landing_id", referencedColumnName="id")} * ) **/ protected $landings; } 

Now I want to select all splittests with more than one landing. How can I do this in DQL?

1 Answer 1

1

You'll need to use having to select all splittest with more than 1 landing

SELECT s FROM MyBundle\Entity\Splittest JOIN s.landings l HAVING COUNT(l) > 1 

same in using query builder

$qb->select("s") ->from('MyBundle\Entity\Splittest', 's') ->innerJoin('s.landings', 'l') ->having('count(l) > 1'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.