I have two tables , Website and user_website_map
I want to select Websites with nested select condition
Code is this
$query = \Website::query()->addWhere('id in (SELECT user_website_map.website_id from security.user_website_map where user_id = :userId )', [':userId' => $this->getId()]) ;
return $query->execute();
This statements throws exception
Phalcon\Mvc\Model\Exception: Syntax error, unexpected token SELECT, near to ' user_website_map.website_id from security.user_website_map where user_id = :userId )', when parsing: SELECT [Website].* FROM [Website] WHERE id in (SELECT user_website_map.website_id from security.user_website_map where user_id = :userId ) (138)
If i execute this query from db console no error occures.
SELECT * FROM main.website WHERE id in (SELECT user_website_map.website_id from security.user_website_map where user_id = 2)
For information I am using postgresql-9.4 and Phalcon 1.3.4 What is wrong with this statements ?