We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Query SQL error with LEFT OUTER JOIN in Phalcon

Hi all, I want to create menu multi level and I follow the instructions at https://wizardinternetsolutions.com/articles/web-programming/dynamic-multilevel-css-menu-php-mysql

But error my query in phalcon:

Error msg: Syntax error, unexpected token (, near to 'SELECT cat_parent_id, COUNT(*) A........

This is my query. Please guide me use the above query in phalcon

$phql  = 'SELECT a.cat_id, b.cat_parent_id, b.Count FROM App\Modules\Page\Models\PageCat a LEFT JOIN (SELECT cat_parent_id, COUNT(*) AS Count FROM App\Modules\Page\Models\PageCat GROUP BY cat_parent_id) b ON a.cat_id = b.cat_parent_id';
$query = $this->modelsManager->createQuery($phql);
$products = $query->execute();

You dont need LEFT JOIN here, just make a subquery.

I donot know subquery. help me example.

You dont need LEFT JOIN here, just make a subquery.