Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question