A
A
Andrey R2015-12-04 13:15:58
symfony
Andrey R, 2015-12-04 13:15:58

How to write Subquery in Doctrine Query Builder?

Hello! Good day!
Essence of a question: It is necessary to write a subquery in dql. I can't find anything useful on the net. Can you show a working example please.
There is the following sql it needs to be paid. If you can help me with this I will be grateful.
select
dbo.Companies.Id,
dbo.Companies.Name,
dbo.Companies.LastSentQuestionDate,
dbo.AnswersWorkers.D,
dbo.AnswersPatients.D
from dbo.Companies
inner join dbo.Organizations ON dbo.Organizations.CompanyId = dbo.Companies. Id
inner join dbo.AnswersPatients
ON dbo.AnswersPatients.CompanyC = dbo.Companies.Id
Where
dbo.AnswersWorkers.D = (
select max(D) from dbo.AnswersWorkers as a
where a.CompanyC = dbo.Companies.Id
)
AND
dbo.AnswersPatients.D = (
select max(D) from dbo.AnswersPatients as p
where p.CompanyC = dbo.Companies.Id
)
Group By
dbo.Companies.Id,
dbo.Companies.Name,
dbo.Companies.LastSentQuestionDate,
dbo.AnswersWorkers.D,
dbo.AnswersPatients.D
;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Skobkin, 2015-12-04
@skobkin

www.stackoverflow.com/a/11925750

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question