我想在一個學說來創建此SQL查詢QueryBuilder SELECT count(DISTINCT d.id)
FROM `discount` d
JOIN `order_discount_relationships` od ON od.discount_id = d.id
JOIN `orders` o ON o.id = od.order_id
WHERE o.status = 3
我需要將此sql查詢更改爲原則查詢或dql表單。這可能嗎? SELECT count(*) AS listenCount, l.post_id AS postId
FROM (SELECT DISTINCT ll.user_id, ll.post_id FROM listen ll) l
WHERE l.post_id IN (' . $id . ')
GROUP BY l.post_id
所以我有這樣的數據庫設置。 電話號碼屬於分組。用戶也屬於分組。我試圖弄清楚如何獲得屬於一個分組的所有用戶,但是通過實體對象而不是隻是一個查詢,如果這是可能的話。 比如我知道我能做到這樣的查詢... <?php
/**
* Auto generated by MySQL Workbench Schema Exporter.
* Version 3.0.3 (doctrine2-annotat