Hi Zarloc, The first query will always produce no results:
"SELECT p FROM Module\Entity\Product p JOIN p.subcategories s WHERE s.id =1 AND s.id = 3" This is looking for a subcategory that has both ID 1 and 3 - that is obviously not possible. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 6 February 2014 18:10, zarloc <[email protected]> wrote: > Hi, > i have this entity: > > Category----->---OneToMany--->Subcategory----->ManyToMany----->Product > > I have to find the products that have the subcategory 1 and 3 > > Use the following query > > SELECT p FROM Module\Entity\Product p JOIN p.subcategories s WHERE s.id=1 AND > s.id = 3 > > but I get 0 results. > > if i use the following query > > SELECT p FROM Module\Entity\Product p JOIN p.subcategories s WHERE s.idIN ( > 1, 3 ) > > I find all the products you have 1 OR 3 > > but I have to find products that have both 1 and 3 > > where am I wrong? > > -- > 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/groups/opt_out. > -- 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/groups/opt_out.
