DDC-2852: Enclose subquery with parenthesis in from clause (QueryBuilder) #3560

Open
opened 2026-01-22 14:22:35 +01:00 by admin · 1 comment
Owner

Originally created by @doctrinebot on GitHub (Dec 12, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user houpli:

Hi

In QueryBuilder from clause, when argument is a QueryBuilder (not a string like a table), there are not parenthesis enclosure on the subquery.

Ex:
$subqb->select('myfield')->from('mytable');
$qb->from($sub, 'myalias)

DQL is : SELECT myfield FROM SELECT myField FROM mytable myalias. This is not working on MySQL.

It should be : SELECT myfield FROM (SELECT myField FROM mytable) myalias.

Originally created by @doctrinebot on GitHub (Dec 12, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user houpli: Hi In QueryBuilder from clause, when argument is a QueryBuilder (not a string like a table), there are not parenthesis enclosure on the subquery. Ex: $subqb->select('myfield')->from('mytable'); $qb->from($sub, 'myalias) DQL is : SELECT myfield FROM SELECT myField FROM mytable myalias. This is not working on MySQL. It should be : SELECT myfield FROM (SELECT myField FROM mytable) myalias.
admin added the Improvement label 2026-01-22 14:22:35 +01:00
Author
Owner

@doctrinebot commented on GitHub (Dec 12, 2013):

Comment created by stof:

I don't understand your statement This is not working on MySQL. after giving a DQL statement. MySQL does not support any DQL. It runs SQL.

And DQL does not support using a subselect in the FROM clause

@doctrinebot commented on GitHub (Dec 12, 2013): Comment created by stof: I don't understand your statement `This is not working on MySQL.` after giving a DQL statement. MySQL does not support any DQL. It runs SQL. And DQL does not support using a subselect in the FROM clause
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3560