I've a SQL query (2 variants) and I need to use it with dynamic queries.
In SQL it looks so (Variant 1 // via subquery):
SELECT AssetEntry.entryId , (
SELECT COUNT(*)
FROM `MBMessage`
WHERE classPK = AssetEntry.classPK
) AS comments
FROM `AssetEntry`
ORDER BY comments DESC
Or the alternative query with join and group:
SELECT AssetEntry.entryId, count(MBMessage.classPK)
FROM `AssetEntry`
JOIN MBMessage ON (AssetEntry.classPK = MBMessage.classPK)
GROUP BY MBMessage.classPK
Both SQL Queries displays exactly the same!
Now I need to use one of them as dynamic query. I have no idea how to do a join and I have no idea how to do a subquery in the projection?!
Can anybody help me? THX
I had to do this with custom-sql.
You have another way of doing this, With AssetEntryQuery.