mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Use subquery in join #5912
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kleinpetr on GitHub (Mar 6, 2018).
Originally assigned to: @Ocramius on GitHub.
is here some way how can I use SubQuery in innerJoin via doctrin queryBuilder() ?
Something like this
Thank you so much.
@Ocramius commented on GitHub (Mar 6, 2018):
@kleinpetr sub-queries cannot be joined with in DQL, because the type of the subquery is not necessarily well-defined.
@kleinpetr commented on GitHub (Mar 9, 2018):
So how can I use this example ?
@Ocramius commented on GitHub (Mar 9, 2018):
You'd need to either make two subsequent queries with an
IN()condition on the second one that restricts the search over identifiers, or an SQL query.@kleinpetr commented on GitHub (Mar 9, 2018):
can you show on this example please ? If I understand, INNER JOIN work as WHERE condition, so I must get array of minimal prices and use this array as IN
@Ocramius commented on GitHub (Mar 9, 2018):
Something like:
Then run a second query against it.
@kleinpetr commented on GitHub (Mar 9, 2018):
yes or maybe I can use something like this.
I have array, where I have h.id and his minimalPrice
And then I use second query with IN condition where I use the array of values the finish query could be
WHERE h.id = 10 AND final_price = 200 OR h.id = 12 AND final_price = 150
Its the same as that INNER JOIN no ?
but I dont know how can I use multiple IN() probably like this
WHERE (h.id, t.final_price) IN ((10,200),(12,150))
it will work in Criteria expr ??
@stollr commented on GitHub (Sep 10, 2018):
@Ocramius can you explain this a bit more? I have use cases where a join into a subquery is needed to get the correct results. For example in paginated lists where aggregated data should be shown.