Answer the question
In order to leave comments, you need to log in
How to execute a subquery using PHQL?
There is a request like this:
SELECT Messages.*
FROM (
SELECT MAX(id) AS 'maxid', IF (author = 'Gildars', recipient, author) AS 'user'
FROM Messages
WHERE author = 'Gildars' or recipient = 'Gildars'
GROUP BY user
) AS a
INNER JOIN Messages ON a.maxid = id
ORDER BY id DESC
$this->modelsManager->executeQuery("SELECT Aincrad\Models\Messages.*
FROM (
SELECT MAX(id) AS 'maxid', IF (author = 'Gildars', recipient, author) AS 'user'
FROM Aincrad\Models\Messages
WHERE author = 'Gildars' or recipient = 'Gildars'
GROUP BY user
) AS a
INNER JOIN Aincrad\Models\Messages ON a.maxid = id
ORDER BY id DESC
");
Syntax error, unexpected token (, near to ' SELECT MAX(id) AS 'maxid', IF (author = 'Gildars', recipient, author) AS 'user' FROM Aincrad\Models\Messages WHERE author = 'Gildars' or recipient = 'Gildars' GROUP BY user ) AS a INNER JOIN Aincrad\Models\Messages ON a.maxid = id ORDER BY id DESC ', when parsing: SELECT Aincrad\Models\Messages.* FROM ( SELECT MAX(id) AS 'maxid', IF (author = 'Gildars', recipient, author) AS 'user' FROM Aincrad\Models\Messages WHERE author = 'Gildars' or recipient = 'Gildars' GROUP BY user ) AS a INNER JOIN Aincrad\Models\Messages ON a.maxid = id ORDER BY id DESC (314)
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