[TYPO3-mvc] many to many relations, with 2 categories

Muriel le Pair typo3 at strangefruit.nl
Sat Jun 28 12:14:41 CEST 2014


Hi,

I'm struggling with the many to many relations.

I need to know how many records there are for each category.
The prefered output is 0 if there are none.

So for instance:
cat 1 [4]
cat 2 [0]
cat 2 [1]

The query below gives the correct output:

SELECT count(mm.uid_foreign) as amount,
c.*
FROM tx_sffilterdb_domain_model_cataardvdaanpak as c
LEFT JOIN tx_sffilterdb_items_cataardvdaanpak_mm as mm ON (c.uid = 
mm.uid_foreign)
WHERE c.deleted=0
AND (c.t3ver_wsid=0 OR c.t3ver_wsid=0)
AND c.pid<>-1
GROUP BY c.uid
ORDER BY c.sorting ASC

But how do I select all records that have cat 1 AND cat 2 (mm.uid_local 
= 1 AND mm.uid_local =2)?

--
kind regards,

Muriel le Pair



More information about the TYPO3-project-typo3v4mvc mailing list