Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Query error

What is wrong with this query?

I get the error: Scanning error before 'Apponte\Models\E...' when parsing: SELECT a.id, a.label, a.link, Deriv1.Count FROM Apponte\Models\Entities\Menu a LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM Apponte\Models\Entities\Menu GROUP BY parent) Deriv1 ON a.id = Deriv1.parent where id=5 (226)

        $query = new Query("SELECT a.id, a.label, a.link, Deriv1.Count FROM `Apponte\Models\Entities\Menu` a  LEFT OUTER JOIN (SELECT parent, COUNT(*) AS Count FROM `Apponte\Models\Entities\Menu` GROUP BY parent) Deriv1 ON a.id = Deriv1.parent where id=5", $this->getDI());
        // Execute the query returning a result if any
        $menu = $query->execute();


84.5k
Accepted
answer

This syntax is not supported in PHQL

What's the better way to do complex queries?