Support Topics Documentation Slack YouTube Blog

Query that is based on results of another query

(SnakeEyes) #1

Hello guys
I was wondering if I can do query where the “where clause” is based on results of another query.

For example.
Issue a query using the find method on the Blog table and the where clause is
“Blog.poster.objId = (objId in (Users[following.objId= ‘xxxx’].objId))”

Here I am getting the posts made by the users that user xxx follows.

Thank yoi

(Sergey Chupov) #2

You can indeed use a subquery, but the outer comparison in your query isn’t correct: the (objId in (...)) returns a boolean value, and you’re comparing it to a string value of Blog.poster.objId.